모델에 대해 추가 제거 기능을 사용하고 notifyPropertyChanged()
을 호출하여보기 변경을 알릴 수 있습니다.
class MyPojo extends BaseObservable {
HashMap<String, Friend> friends;
@Bindable
public HashMap<String, Friend> getFriends(){
return friends;
}
public void setFriends(HashMap<String,Friend> newFriends){
friends=newFriends;
notifyPropertyChanged(BR.friends);
}
public void add(String str,Friend friend)
{
friends.put(str,friend);
notifyPropertyChanged(BR.friends);
}
public void remove(String str,Friend friend)
{
friends.remove(str,friend);
notifyPropertyChanged(BR.friends);
}
}
이 데이터를 listview 또는 gridview에 사용 하시겠습니까 ?? –
@Chandra 목록입니다. 하지만 RecyclerView 또는 ListView는 아닙니다. – kirtan403
listview 또는 gridview를 사용하고 있다면 adapter.notifyDataSetChanged();를 사용할 수 있습니다. 그것을 위해. –