Changes

Jump to: navigation, search

An Android Jetpack LiveData Tutorial

69 bytes removed, 18:36, 16 January 2019
Implementing the Observer
</pre>
== Implementing Implementing the Observer ==
Now that the conversion result is contained within a LiveData instance, the next step is to configure an observer within the UI controller which, in this example, is the MainFragment class. Locate the MainFragment.java class (app -> java -> <package name> -> MainFragment), double-click on it to load it into the editor and modify the onActivityCreated() method to create a new Observer instance named resultObserver:
    resultText = getView().findViewById(R.id.resultText);
    convertButton = getView().findViewById(R.id.convertButton);
 
    resultText.setText(mViewModel.getResult().toString());
 
    final Observer<Float> resultObserver = new Observer<Float>() {

Navigation menu