Advertisement
Sebuahhobi98

fragmentToggle

Aug 29th, 2021
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public class HomeFragment extends Fragment {
  2.  
  3. private HomeViewModel homeViewModel;
  4. JellyToggleButton jellyToggleButton;
  5. Toast lastToast;
  6. public View onCreateView(@NonNull LayoutInflater inflater,
  7. ViewGroup container, Bundle savedInstanceState) {
  8. homeViewModel =
  9. new ViewModelProvider(this).get(HomeViewModel.class);
  10. View root = inflater.inflate(R.layout.fragment_home, container, false);
  11. jellyToggleButton = (JellyToggleButton) getActivity().findViewById(R.id.relay);
  12. jellyToggleButton.setOnStateChangeListener(new JellyToggleButton.OnStateChangeListener() {
  13. @Override
  14. public void onStateChange(float process, State state, JellyToggleButton jtb) {
  15. if (state.equals(State.LEFT)) {
  16. Log.d(TAG, "onStateChange: Left");
  17. }
  18. if (state.equals(State.RIGHT)) {
  19. Log.d(TAG, "onStateChange: Right");
  20. }
  21. }
  22. });
  23. return root;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement