【发布时间】:2020-05-29 07:17:09
【问题描述】:
我想给我的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"
}
}
但是会出现编译错误,因为委托属性无法保存在数据库中。所以我想
添加一个
Ignore 对此字段的注释。可惜Androidstuio会报错"This annotation is not applicable to target 'member property with delegate"。谁有这个问题的想法?
【问题讨论】:
-
@delegate:Ignore
标签: kotlin android-room