You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AreaFragment.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.example.meinwald.ui.area;
  2. import android.os.Bundle;
  3. import android.view.LayoutInflater;
  4. import android.view.View;
  5. import android.view.ViewGroup;
  6. import android.widget.TextView;
  7. import androidx.annotation.NonNull;
  8. import androidx.annotation.Nullable;
  9. import androidx.fragment.app.Fragment;
  10. import androidx.lifecycle.Observer;
  11. import androidx.lifecycle.ViewModelProviders;
  12. import com.example.meinwald.R;
  13. public class AreaFragment extends Fragment {
  14. private DashboardViewModel dashboardViewModel;
  15. public View onCreateView(@NonNull LayoutInflater inflater,
  16. ViewGroup container, Bundle savedInstanceState) {
  17. dashboardViewModel =
  18. ViewModelProviders.of(this).get(DashboardViewModel.class);
  19. View root = inflater.inflate(R.layout.fragment_areas, container, false);
  20. final TextView textView = root.findViewById(R.id.text_areas);
  21. dashboardViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
  22. @Override
  23. public void onChanged(@Nullable String s) {
  24. textView.setText(s);
  25. }
  26. });
  27. return root;
  28. }
  29. }