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' 
解决该问题的问题
相关问题