Cyr*_*rus 6 kotlin android-room
我想在我的Composition类中添加一个委托属性,如下
@Entity
data class Composition(
val author: String="",
val background: String?,
val description: String="",
val downloadURL: String="",
val duration: String="",
val headPortrait: String?,
@PrimaryKey val id: String,
val isLike: Boolean,
val likeAmount: String="",
val playingAmount: Int=0,
val replyAmount: String?,
val showStyle: String?,
val title: String?,
val userId: String?,
val commentAmount: String?,
val cover: String=""
){
val showDuration by lazy{
val minutes = duration.toInt() /60
val seconds =duration.toInt()%60
"$minutes:$seconds"
}
}
Run Code Online (Sandbox Code Playgroud)
但是会出现编译错误,因为委托属性无法保存在数据库中。所以我想Ignore给这个字段添加一个
注释。可惜Androidstuio 会抛出一个抱怨“此注释不适用于目标'成员属性与委托”。谁有这个问题的想法?
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |