So my menu items wont do anything except show the enlarging animation when clicked on. Im trying to open a new activity with them, I have toast attached to one to see if does an
onOptionsItemSelected
is not meant to handle action on BottomNavigationView
. Action on MenuItem
in BottomNavigationView
should be done as follows:
BottomNavigationView bottomNavigationView = findViewById(R.id.navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView
.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.navigation_home) {
Intent navHome = new Intent(MainActivity.this, WordpressActivity.class);
MainActivity.this.startActivity(navHome);
return true;
}
if (id == R.id.navigation_apps) {
Toast.makeText(MainActivity.this, "apps is Clicked", Toast.LENGTH_LONG).show();
return true;
}
if (id == R.id.navigation_profile) {
Intent navProf = new Intent(MainActivity.this, AccountActivity.class);
MainActivity.this.startActivity(navProf);
return true;
}
if (id == R.id.navigation_logout) {
Intent navLog = new Intent(MainActivity.this, LogoutActivity.class);
MainActivity.this.startActivity(navLog);
return true;
}
return false;
});