我使用的导航从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?