gpt4 book ai didi

android - 为什么导航组件 fragment 标签不起作用

转载 作者:行者123 更新时间:2023-12-03 08:48:24 28 4
gpt4 key购买 nike

你好,我正在更改导航文件中 fragment 的标签,但工具栏中的 fragment 标题没有改变,有什么解决方案吗?

 <fragment
android:id="@+id/navHostFragment"
android:name="com.example.androidtask.view.UsersList"
android:label="@string/user_list"
tools:layout="@layout/fragment_users_list">
<action
android:id="@+id/submit_user"
app:destination="@id/addUser" />

</fragment>

最佳答案

您需要设置 ActionBar 才能与导航一起使用,请在 Activity onCreate() 中添加此代码

val navController = findNavController(R.id.nav_host_fragment)// where nav_host_fragment is the id for your Main NavHost fragment
val appBarConfiguration = AppBarConfiguration(navController.graph)
setupActionBarWithNavController(navController, appBarConfiguration)

了解更多信息请查看this

关于android - 为什么导航组件 fragment 标签不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60464351/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com