相关疑难解决方法(0)

是否可以使用Android导航架构组件(Android Jetpack)有条件地设置startDestination?

我使用的导航Android的Jetpack的屏幕之间进行导航.现在我想动态设置startDestination.

我有一个名为MainActivity的Activity和两个Fragments,FragmentA和FragmentB.

var isAllSetUp : Boolean = // It is dynamic and I’m getting this from Preferences.

    If(isAllSetUp)
    {
     // show FragmentA
    }
    else
    {
     //show FragmentB
    }
Run Code Online (Sandbox Code Playgroud)

我想使用Navigation Architecture Component设置上面的流程.目前我使用startDestionation如下所示,但它不符合我的要求.

<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/lrf_navigation"
   app:startDestination="@id/fragmentA">

   <fragment
       android:id="@+id/fragmentA"
       android:name="com.mindinventory.FragmentA"
       android:label="fragment_a"
       tools:layout="@layout/fragment_a" />
</navigation>
Run Code Online (Sandbox Code Playgroud)

是否可以使用Android导航架构组件有条件地设置startDestination?

android android-jetpack android-architecture-navigation

31
推荐指数
3
解决办法
9029
查看次数