我是 android 数据绑定的新手,我正在查看如下代码
@get:Bindable
var userIds: MutableList<Long> = mutableListOf()
private set(value) {
field = value
notifyPropertyChanged(BR.userIds)
}
Run Code Online (Sandbox Code Playgroud)
那么,@get:Bindable这里有什么。是@Bindable和@get:Bindable一样吗?
@get:Bindable简单来说,这将
@Bindable在 getter 上添加注释userIds。
下面两个是相同的。或者你可以说两种在 getter 上添加注解的方法。
@get:Bindable
var userIds: MutableList<Long> = mutableListOf()
private set(value) {
field = value
notifyPropertyChanged(BR.userIds)
}
var userIds: MutableList<Long> = mutableListOf()
@Bindable get() = _title
set(value) {
field = value
notifyPropertyChanged(BR.userIds)
}
Run Code Online (Sandbox Code Playgroud)
private ArrayList<Long> userIds = new ArrayList<>();
@Bindable
public ArrayList<Long> getUserIds() {
return userIds;
}
public void setUserIds(ArrayList<Long> userIds) {
this.userIds = userIds;
notifyPropertyChanged(BR.selected);
}
Run Code Online (Sandbox Code Playgroud)
您可以在官方文档中了解更多关于 Annotations 的信息。
| 归档时间: |
|
| 查看次数: |
2028 次 |
| 最近记录: |