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());
}
}
我有參考下面的示例:
我提出HERE
任何幫助,將不勝感激