I'm trying to use Bottom Navigation View to open another activity when clicked. For some reason, I'm getting an error on the last line, which should define the click function. I tested it on another project, and it worked perfectly.
Here's the end part of my Activity:
private BottomNavigationView.OnNavigationItemSelectedListener
mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
Intent kampIntent = new Intent(SortimentActivity.this, CampaignActivity.class);
startActivity(kampIntent);
mTextMessage.setText(R.string.title_home);
break;
case R.id.navigation_dashboard:
mTextMessage.setText(R.string.title_dashboard);
break;
}
return false;
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
I tried the exact same code in another project, and it worked. The error, which I get here, is
'Cannot resolve symbol' .setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Any ideas on what went wrong here?