这是我的 onNavigationItemSelected 方法:
}
最佳答案
这样做:
int id = item.getItemId();
FragmentTransaction fragmentTransaction;
if (id == R.id.nav_sports) {
fragment = new FragmentOne();
} else if (id == R.id.nav_food) {
fragment = new FragmentTwo();
} else if (id == R.id.nav_security) {
fragment = new FragmentThree();
}
if (fragment != null) {
fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.containerView, fragment).commit();
}
关于java - 当我使用 map View 按导航项两次时,我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39202177/