android - 当我们转到其他图形时如何在抽屉中显示汉堡包(具有多模块的导航组件)
问题描述
我用多模块制作应用程序:-app-SMS
现在我在模块应用程序中绘制图表:
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mobile_navigation"
app:startDestination="@+id/nav_home">
<include app:graph="@navigation/sms_navigation" />
<fragment
android:id="@+id/nav_home"
android:name="com.example.messages.ui.home.HomeFragment"
android:label="@string/menu_home"
tools:layout="@layout/fragment_home" />
<fragment
android:id="@+id/nav_sms"
android:name="com.example.messages.ui.sms.SmsFragment"
android:label="@string/menu_sms"
tools:layout="@layout/fragment_sms">
<action
android:id="@+id/action_sms_not_met"
app:destination="@id/sms_navigation"/>
</fragment>
<fragment
android:id="@+id/nav_preferences"
... />
<fragment ... />
</navigation>
并在模块 SMS
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sms_navigation"
app:startDestination="@id/nav_sms_welcome_fragment">
<fragment
android:id="@+id/nav_sms_welcome_fragment"
android:name="com.example.sms.ui.welcome.WelcomeFragment"
android:label="@string/welcome"
tools:layout="@layout/list_sms_fragment">
<action
android:id="@+id/openListSms"
app:destination="@+id/nav_sms_list_fragment"
/>
</fragment>
<fragment
android:id="@+id/nav_sms_list_fragment"
android:name="com.example.sms.ui.listsms.ListSmsFragment"
android:label="@string/list_sms"
tools:layout="@layout/list_sms_fragment" />
</navigation>
当我运行应用程序时,我看到了主页片段和抽屉的汉堡包。接下来我打开抽屉并单击“短信”行。如果变量“enableSMS”为假,则显示欢迎片段,否则打开“短信列表片段”。
问题 1:当我在那里(短信列表片段)时,我看到按钮向上。我想看到汉堡包而不是按钮向上。打开设置或主页片段时就可以了。我该如何解决?
问题2 该案例可能与第一个问题有关当我打开短信列表片段并按后退按钮时,我将返回片段欢迎一段时间并再次向我显示短信列表片段。我无法返回首页片段,因为我有循环。在片段(短信和欢迎)中,我有代码:
// SmsFragment
if (enableSMS) findNavController().navigate(R.id.action_sms_not_met)
// WelcomeFragment
if (enableSMS) findNavController().navigate(com.example.sms.R.id.openListSms)
如果我从主页片段开始,然后转到 sms 列表片段,我按下后退按钮我想查看主页片段,因为它是打开 sms 片段之前的第一个片段。
任何想法?
感谢帮助 :)
解决方案
推荐阅读
- sql - 选择上一个动作之后的第一个动作实例
- typescript - 如何将导出的 keyof 转换为字符串类型
- javascript - 打开 Chrome Devtools 重新加载 Hulu 会导致奇怪的行为
- postgresql - Peewee SQL - 如何在查询中使用 Python any() 和 all() 运算符
- python-3.x - 与直接在笔记本中的 colab 上运行相同的代码相比,在 colab 中运行 python 脚本非常慢
- aws-lambda - AWS HTTP API Gateway:阶段变量
- python - ModuleNotFoundError:没有名为“PIL”的模块
- javascript - React.js useRef钩子没有返回预期的对象
- go - 为什么 Go 经常将字符串的数据存储在未对齐的地址
- java - 匹配两个 MultivaluedMap 并检索值