Updating UI using ViewModel and DataBinding

后端 未结 3 548
清酒与你
清酒与你 2021-01-31 20:09

I am trying learn View-model android ,in my first phase of learning i am trying to update UI (Textview) by using view-model and data-binding. In View model i am having aynctask

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 20:28

    You'll require to notify observer when you set value like this :

    public class UserData extends BaseObservable{
    private String firstName ;
    @Bindable
    public String getFirstName() {
        return firstName;
    }
    
    public void setFirstName(String firstName) {
        this.firstName = firstName;
        notifyPropertyChanged(BR.firstName) // call like this
    }
    }
    

提交回复
热议问题