- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的场景就像我有一个包含(登录/注册 fragment )的 MainActivity。我有一个 HomeActivity(其中包含带有抽屉布局的导航 View 。)
这两个 Activity 都有各自独立的导航图。当我在 main_navigation_graph 中包含 home_navigation_graph 并导航到它时,DrawerLayout 不起作用。但是当我单独做这件事时,就像没有嵌套只调用 home_navigation_graph(HomeActivity) 作为启动器一样,一切正常。这是我的示例代码:
<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/nav_graph_login"
app:startDestination="@id/loginFragment">
<fragment
android:id="@+id/loginFragment"
android:name="com.example.app.ui.login.LoginFragment"
android:label="LoginFragment"
tools:layout="@layout/fragment_login">
<action
android:id="@+id/action_loginFragment_to_signupFragment"
app:destination="@id/signupFragment" />
<action
android:id="@+id/action_loginFragment_to_mobile_navigation"
app:destination="@id/mobile_navigation"
app:launchSingleTop="true"
app:popUpTo="@+id/nav_graph_login"
app:popUpToInclusive="true" />
</fragment>
<fragment
android:id="@+id/signupFragment"
android:name="com.example.app.ui.signup.SignupFragment"
android:label="SignupFragment"
tools:layout="@layout/fragment_signup">
<action
android:id="@+id/action_signupFragment_to_loginFragment"
app:destination="@id/loginFragment"
app:launchSingleTop="true"
app:popUpTo="@id/signupFragment"
app:popUpToInclusive="true" />
</fragment>
<include app:graph="@navigation/mobile_navigation" />
</navigation>
当我在单击登录按钮时调用第二个移动导航图(使用代码 belwo)时,HomeActivity 打开但只有 homeDestinationFragment 是可见的,其余没有任何作用
findNavController().navigate(R.id.action_loginFragment_to_mobile_navigation)
下面的代码是 home_navigation_graph.xml
<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">
<fragment
android:id="@+id/nav_home"
android:name="com.example.app.ui.home.HomeFragment"
android:label="@string/menu_home"
tools:layout="@layout/fragment_home" />
<fragment
android:id="@+id/nav_gallery"
android:name="com.example.app.ui.earnings.VendorEarningFragment"
android:label="@string/menu_vendor_earning"
tools:layout="@layout/fragment_vendor_earning" />
<fragment
android:id="@+id/nav_slideshow"
android:name="com.example.app.ui.slideshow.SlideshowFragment"
android:label="@string/menu_slideshow"
tools:layout="@layout/fragment_slideshow" />
<fragment
android:id="@+id/nav_tools"
android:name="com.example.app.ui.tools.ToolsFragment"
android:label="@string/menu_tools"
tools:layout="@layout/fragment_tools" />
<fragment
android:id="@+id/nav_share"
android:name="com.example.app.ui.share.ShareFragment"
android:label="@string/menu_share"
tools:layout="@layout/fragment_share" />
<fragment
android:id="@+id/nav_send"
android:name="com.example.app.ui.send.SendFragment"
android:label="@string/menu_send"
tools:layout="@layout/fragment_send" />
</navigation>
请让我知道我缺少什么。我被困在这几个星期了。
最佳答案
在您的 home_navigation_graph 中只包含抽屉布局和导航菜单而不是整个图表。它对我来说效果很好,您可以查看我的 github 存储库。
替换下面几行
<include app:graph="@navigation/mobile_navigation" />
下面是这段代码
<activity
android:id="@+id/mainActivity"
android:name="com.example.nav_experiment.MainActivity"
android:label="activity_main"
tools:layout="@layout/activity_main" />
在下面的 Git 链接中有抽屉导航,它在登录按钮单击时打开,根据查询要求
详细说明按照 git 链接 -> https://github.com/gautammittal23/NaV_Graph_With_login_navigation_drawer
关于java - 带有 NavigationView 的嵌套导航图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58993504/
我有三个 Controller 。让我们依次说 Controller A、B 和 C。 Controller A 中的导航标题颜色为红色。 Controller B 为蓝色, Controller C
我有一个导航图,它使用此 fragment 作为主 Activity XML 中的主页。 我有一个带有菜单的抽屉布局,当我单击抽屉导航按钮时,我无法使导航正常工作(它在主 fragm
我是一名优秀的程序员,十分优秀!