【发布时间】:2020-06-08 09:55:08
【问题描述】:
工具栏上有一个设置按钮,可以打开一个片段,其中包含打开更多片段的选项列表。
设置页面有 2 个选项
- 简介
- 更改密码
用户可以导航到任何页面,并且工具栏对每个页面的用户都是可见的
如果我单击配置文件 -> 启动配置文件片段 -> 然后我单击工具栏上的设置 -> 启动设置页面
现在,当我按下返回时,我被重定向到我不希望发生的配置文件片段。 它应该重定向到设置片段之前访问的最后一个页面,因为配置文件和密码片段是设置片段的子片段
这是我的设置片段流导航图
<fragment
android:id="@+id/settingsFragment"
android:name="com.mountmeru.view.settings.SettingsFragment"
android:label="fragment_settings"
tools:layout="@layout/fragment_settings">
<action
android:id="@+id/action_settingsFragment_to_profileFragment"
app:destination="@id/profileFragment" />
<action
android:id="@+id/action_settingsFragment_to_resetPasswordFragment"
app:destination="@id/resetPasswordFragment" />
</fragment>
这就是我导航到个人资料和密码片段的方式
view.findNavController().navigate(
R.id.action_settingsFragment_to_profileFragment)
view.findNavController().navigate(
R.id.action_settingsFragment_to_resetPasswordFragment)
【问题讨论】:
标签: android navigation fragment android-architecture-navigation android-jetpack-navigation