bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_home:
// do something here
return true;
case R.id.action_message:
// do something here
return true;
case R.id.action_compose:
// do something here
return true;
case R.id.action_profile:
// do something here
return true;
default: return true;
}
}
});
this is code to implement the bottom navigation into the project
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.action_home: // do something here return true; case R.id.action_message: // do something here return true; case R.id.action_compose: // do something here return true; case R.id.action_profile: // do something here return true; default: return true; } } });