Changes

Jump to: navigation, search

An Android Navigation Component Tutorial

250 bytes removed, 18:48, 16 January 2019
Declaring a Navigation Host
Before adding any destinations to the navigation graph, the next step is to add a navigation host fragment to the project.
== Declaring Declaring a Navigation Host ==
For this project, the navigation host fragment will be contained within the user interface layout of the main activity. This means that the destination fragments within the navigation graph will appear in the content area of the main activity currently occupied by the main_fragment.xml layout. Locate the main activity layout file in the Project tool window (app -> res -> layout -> main_activity.xml) and load it into the layout editor tool.
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, MainFragment.newInstance())
                .commitNow();
    }
}
</pre>
[[File:as_3.2_navigation_navhost_added.png]]
 
== Adding Navigation Destinations ==

Navigation menu