SHARE
TWEET

Untitled

a guest Jun 26th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //BaseActivity
  2. private BottomNavigationView.OnNavigationItemSelectedListener navigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
  3.         @Override
  4.         public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  5.             baseViewModel.navButtonPressed(BaseActivity.this, item.getItemId());
  6.             return true;
  7.         }
  8.     };
  9.  
  10.  
  11. //BaseViewModel
  12. public void navButtonPressed(Context context, int itemId) {
  13.         switch(itemId) {
  14.             case R.id.bottomNav_discover:
  15.                 ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.base_fragment_container, new DiscoverFragment()).commit();
  16.             break;
  17.             case R.id.bottomNav_library:
  18.                 ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.base_fragment_container, new LibraryFragment()).commit();
  19.             break;
  20.             case R.id.bottomNav_community:
  21.                 ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.base_fragment_container, new CommunityFragment()).commit();
  22.             break;
  23.             case R.id.bottomNav_personal:
  24.                 ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction().replace(R.id.base_fragment_container, new PersonalFragment()).commit();
  25.             break;
  26.         }
  27.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top