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
If you want binding layout to work then you have to set your view in binding way. Also set data in binding class.
public class MainActivity extends AppCompatActivity implements LifecycleOwner {
ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
...
ViewModelData model = ViewModelProviders.of(this).get(ViewModelData.class);
...
binding.setData(model.getUsers());
}
}