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
<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
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
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
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With