1234567891011121314151617181920212223242526272829303132333435 |
- package com.example.myapplication.ui.tools;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.TextView;
- import androidx.annotation.Nullable;
- import androidx.annotation.NonNull;
- import androidx.fragment.app.Fragment;
- import androidx.lifecycle.Observer;
- import androidx.lifecycle.ViewModelProviders;
- import com.example.myapplication.R;
- public class ToolsFragment extends Fragment {
- private ToolsViewModel toolsViewModel;
- public View onCreateView(@NonNull LayoutInflater inflater,
- ViewGroup container, Bundle savedInstanceState) {
- toolsViewModel =
- ViewModelProviders.of(this).get(ToolsViewModel.class);
- View root = inflater.inflate(R.layout.fragment_tools, container, false);
- final TextView textView = root.findViewById(R.id.text_tools);
- toolsViewModel.getText().observe(this, new Observer<String>() {
- @Override
- public void onChanged(@Nullable String s) {
- textView.setText(s);
- }
- });
- return root;
- }
- }
|