34.2 Adding LiveData to the ViewModel
Launch Android Studio, open the ViewModelDemo project created in the previous chapter and open the MainViewModel.java file which should currently read as follows:
package com.ebookfrenzy.viewmodeldemo.ui.main;
import androidx.lifecycle.ViewModel;
public class MainViewModel extends ViewModel {
private static final Float rate = 0.74F;
private String dollarText = "";
private Float result = 0F;
public void setAmount(String value) {
this.dollarText = value;
result = Float.parseFloat(dollarText)*rate;
}
public Float getResult()
{
return result;
...