navigationView = (BottomNavigationView) findViewById(R.id.navigation);
navigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
navigationView.postDelayed(() -> {
int itemId = item.getItemId();
System.out.println("it works");
if (itemId == R.id.homeFragment) {
startActivity(new Intent(getApplicationContext(), HomeActivity.class));
} else if (itemId == R.id.searchFragment) {
startActivity(new Intent(getApplicationContext(), SearchActivity.class));
} else if (itemId == R.id.artistFragment) {
startActivity(new Intent(getApplicationContext(), ArtistProfileActivity.class));
} else if (itemId == R.id.libraryFragment) {
startActivity(new Intent(getApplicationContext(), FavoriteActivity.class));
}
finish();
}, 50);
return true;
}
});
The navigation bar is clickable but it does not bring me to the next page There is no error messages. It just stays on the main page. I am not really sure how the BottomNavigationView works and most of this code is from online and I have problems understanding it.