0

我一直試圖實現的尋呼圖書館與谷歌在Android中架構提供客房Component.But其顯示編譯時錯誤在我UserDao尋呼編譯問題:不知道如何將光標轉換成該方法的返回類型

這裏是錯誤:

Error:(22, 42) error: Not sure how to convert a Cursor to this method's return type 

我的問題是什麼返回類型?

UserDao.java

@Dao 
public interface UserDao { 
    @Query("SELECT * FROM user") 
    LiveData<List<User>> getAll(); 

    //Compile Error is here : Not sure how to convert a Cursor to this method's return type 
    @Query("SELECT * FROM user") 
    LivePagedListProvider<Integer, User> userByPagination(); 

} 

這裏UserModel.java

public class UserModel extends AndroidViewModel { 

    private final UserDao userDao; 

    public UserModel(Application application) { 
     super(application); 
     userDao = RoomDB.getDefaultInstance().userDao(); 
    } 

    public LiveData<List<User>> getAllUser() { 
     return userDao.getAll(); 
    } 


    public LiveData<PagedList<User>> getAllUserPagination() { 
     return userDao.userByPagination().create(
       /* initial load position */ 0, 
       new PagedList.Config.Builder() 
         .setEnablePlaceholders(true) 
         .setPageSize(10) 
         .setPrefetchDistance(5) 
         .build()); 
    } 
} 

我有參考下面的示例:

Sample 1

Google Doc

我提出HERE

任何幫助,將不勝感激

回答

0

我通過更新庫到最新版本

compile 'android.arch.persistence.room:runtime:1.0.0-beta2' 
    annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-beta2' 
    compile 'android.arch.paging:runtime:1.0.0-alpha3' 

    compile 'android.arch.lifecycle:runtime:1.0.0-beta2' 
    compile 'android.arch.lifecycle:extensions:1.0.0-beta2' 
    annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-beta2' 
解決該問題的問題
相關問題