nilupeng
2022-01-29 0c89bf11bcddd39b5193bb19e28399648c59a2b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.runt.open.mvvm.ui.main.home;
 
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
 
import com.runt.open.mvvm.base.fragments.BaseFragment;
import com.runt.open.mvvm.databinding.FragmentHomeBinding;
 
public class HomeFragment extends BaseFragment<FragmentHomeBinding,HomeViewModel> {
 
 
 
    @Override
    public void initViews() {
        final TextView textView = binding.textHome;
        viewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);
            }
        });
    }
 
}