【发布时间】:2020-01-13 09:18:21
【问题描述】:
我不知道下面的问题有什么问题?
代码:
CategoryDAO.kt
@Dao
interface CategoryDAO {
@Query("select * from CategoryDesign")
suspend fun getCategory(): MutableLiveData<List<CategoryDesign>>
}
CategoryDesign.kt
@Entity
data class CategoryDesign (
@PrimaryKey
var categoryDesignID:String,
var designImage:String,
var designTitle:String){
constructor() : this("","","")
override fun toString(): String {
return designTitle
}
}
按下运行应用按钮将显示如下错误:
error: Not sure how to convert a Cursor to this method's return type (androidx.lifecycle.MutableLiveData<java.util.List<com.squall.searchdesigner.model.CategoryDesign>>).
public abstract java.lang.Object getCategory(@org.jetbrains.annotations.NotNull()
w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC), android.databinding.annotationprocessor.ProcessDataBinding (DYNAMIC).
依赖:
dependencies {
def room_version = "2.2.3"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
}
【问题讨论】:
-
您可以添加您的
CategoryDesign实体吗? -
你在使用分页库吗?
-
@Md. Asaduzzaman 我添加了 CategoryDesign 实体。
-
@Raghunandan 我使用 ViewPager 和 RecyclerView
标签: android android-sqlite android-room dao