Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

Navigation Preview unavailable in Android Studio 3.2 Preview

I am interested to try the Navigation graph showed in the Android Studio. But I got the preview unavailable after I import the google sample

I used the Android Studio 3.2 Preview Canary 16

enter image description here

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:startDestination="@+id/launcher_home">

    <fragment
        android:id="@+id/launcher_home"
        android:name="com.android.samples.arch.componentsbasicsample.StartFragment"
        android:label="Home">

        <action
            android:id="@+id/end_action"
            app:destination="@id/end_dest" />

    </fragment>

    <fragment
        android:id="@+id/end_dest"
        android:name="com.android.samples.arch.componentsbasicsample.EndFragment"
        android:label="End"
        >

    </fragment>
</navigation>

Update on 10/6/2018:

Even I rebuild the project it doesn't work. But if added new screen, it showed the new one in preview mode

enter image description here

question from:https://stackoverflow.com/questions/50776284/navigation-preview-unavailable-in-android-studio-3-2-preview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should click on "text" tab in navigation editor (xml file of the navigation graph), and add:

tools:layout="@layout/layout_name"

inside destination element.

Should be something like this:

<fragment
    android:id="@+id/someFragment"
    android:name="com.freesoulapps.navigationtest.fragments.SomeFragment"
    android:label="Some Fragment"
    tools:layout="@layout/layout_name">
</fragment>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...