因此,我正在尝试构建一个带有底部导航栏的应用程序,它可以在片段之间切换。我是根据一些文档编写的。
我在互联网上尝试了所有的解决方案,但似乎都不适合我。
错误:
Caused by: java.lang.ClassCastException: com.example.jetpacklesson.MainFragment cannot be cast to androidx.navigation.fragment.NavHostFragment
at com.example.jetpacklesson.MainActivity.onCreate(MainActivity.java:
目前,我使用的是Android的Navigation组件,操作栏标题显示在左侧。然而,我想让它集中起来,让事情变得更整洁,有没有办法做到这一点? Image of the actionbar title that is displayed on the left 活动代码: public class General extends AppCompatActivity {
private BottomNavigationView bottomNavigationView;
private NavController navController;
private AppB
我在我的应用程序中使用android底部导航组件。在我的MainActivity上有以下几行: 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(