这是我要使用NavigationView创建新活动的代码。当我单击每个按钮时,我想在新页面上打开该活动。感谢您的帮助!
activity_profile_drawer_Lout = findViewById(R.id.activity_profile_drawer_Lout);
navigationView = findViewById(R.id.navigationView);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId())
{
case R.id.home_ic:
menuItem.setChecked(true);
displayMessage("going to home...");
activity_profile_drawer_Lout.closeDrawers();
return true;
case R.id.profile_settings_ic:
menuItem.setChecked(true);
displayMessage("going to profile settings...");
activity_profile_drawer_Lout.closeDrawers();
return true;
case R.id.options_ic:
menuItem.setChecked(true);
displayMessage("going to options...");
activity_profile_drawer_Lout.closeDrawers();
return true;
case R.id.signOut_ic:
menuItem.setChecked(true);
displayMessage("signing out...");
activity_profile_drawer_Lout.closeDrawers();
return true;
}
return false;
}
});
}