【发布时间】:2020-08-05 09:37:01
【问题描述】:
我是 Android 新手。底部导航时显示错误。
错误:
Android 错误 java.lang.NullPointerException:尝试调用虚拟方法 'void androidx.appcompat.app.ActionBar.setTitle
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
}
【问题讨论】:
-
第 27 行是什么?
-
我写错了
标签: android