33.2 Adding LiveData to the ViewModel
Launch Android Studio, open the ViewModelDemo project created in the previous chapter and edit 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 usd_to_eu_rate = 0.74F;
private String dollarText = "";
private Float result = 0F;
public void setAmount(String value) {
this.dollarText = value;
result = Float.valueOf(dollarText)*usd_to_eu_rate;
}
public Float getResult()
{
...