bottomNavigationView = findViewById(R.id.bottom_navigation);
getSupportFragmentManager().beginTransaction().replace(R.id.container, homeFragment).commit();
bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.home;
getSupportFragmentManager().beginTransaction().replace(R.id.container, homeFragment).commit();
return true;
case R.id.settings;
getSupportFragmentManager().beginTransaction().replace(R.id.container, settingsFragment).commit();
return true;
}
return false;
}
});
This code "case R.id.home" & "case R.id.settings" I'm getting an error somewhere in this code. it gives this error: ':' or '->' expected
https://www.youtube.com/watch?v=OV25x3a55pk
I'm trying to do it with this video
Change
case R.id.home;tocase R.id.home:(semi-colon to colon). Same for R.id.settings. As in:Note that you may then also get a warning about "non-final resource ids" in "switch case statements explored further here.
One solution to eliminate the anticipated warning is as follows:
Btw, the video did have it as colons.