def nav_version = "1.0.0-alpha06"
// Navigation components
implementation "android.arch.navigation:navigation-fragment:$nav_version"
implementation "android.arch.navigation:navigation-ui:$nav_version"
-
Click File > Settings (Android Studio > Preferences on Mac), select the Experimental category in the left pane, check Enable Navigation Editor, and then restart Android Studio.
-
In the Project window, right-click on the res directory and select New > Android Resource File. The New Resource File dialog appears.
-
Type a name in the File name field, such as "nav_graph".
-
Select Navigation from the Resource type drop-down list.
-
Click OK. The following occurs:
- A navigation resource directory is created within the res directory.
- A nav_graph.xml file is created within the navigation directory.
- The nav_graph.xml file opens in the Navigation Editor. This xml file contains your navigation graph.
- Click the Text tab to toggle to the XML text view. The XML for an empty navigation graph looks like this:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android">
...
</navigation>
- Click Design to return to the Navigation Editor.
<?xml version="1.0" encoding="utf-8"?>
<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/nav_graph"
app:startDestination="@id/defaultFragment">
<fragment
android:id="@+id/firstFragment"
android:name="com.example.umangburman.navdrawerwithnavcomponent.FirstFragment"
android:label="First Fragment"
tools:layout="@layout/first_fragment" />
<fragment
android:id="@+id/secondFragment"
android:name="com.example.umangburman.navdrawerwithnavcomponent.SecondFragment"
android:label="Second Fragment"
tools:layout="@layout/second_fragment" />
<fragment
android:id="@+id/thirdFragment"
android:name="com.example.umangburman.navdrawerwithnavcomponent.ThirdFragment"
android:label="Third Fragment"
tools:layout="@layout/third_fragment" />
<fragment
android:id="@+id/defaultFragment"
android:name="com.example.umangburman.navdrawerwithnavcomponent.DefaultFragment"
android:label="Default Fragment"
tools:layout="@layout/default_fragment" >
</fragment>
</navigation>
- Lucas Lima
- 📧 e-mail: [email protected]
Copyright 2018 Lucas Lima
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.