Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 671
Long Ranger Avatar asked Jun 09 '18 16:06

Long Ranger


People also ask

How to add a preview in a navigation XML file?

there is another way to have the preview in navigation xml. First go in your xml fragment add if you go in your navigation file you can see the preview inside the selection and the navigation editor

How to add a preview before adding the fragment in navigation?

if you go in your navigation file you can see the preview inside the selection and the navigation editor For me is more logic to have the preview before add the fragment in the navigation editor. May be there are method for add automatically the tools:context in the layout

How to invalidate caches/restart in Android Studio?

So to Invalidate caches/ Restart, go to the file which is present in the top menu bar in Android Studio and then click on the option “Invalidate Caches/Restart…” present in the Dropdown. After that it will ask you that “Would you like to continue?”, click on Invalidate and Restart button. Below are the screenshots to show you the process: Method 3.

How to fix Android APK not working in Android Studio?

Sometimes the android apk support is not working properly in Android Studio. In order to fix that we have to apply a hack. To start with it, firstly we have to go settings that are present in the file or you can also use a shortcut of Ctrl+Alt+S. After clicking on settings, a new window will appear showing you all the settings that you can change.


1 Answers

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> 
like image 194
Alex Avatar answered Sep 22 '22 04:09

Alex