Go to Android Studio,start new project and enter the desired name for your app.Then, in the next step Select the Navigation Drawer Activity and click Next. As shown below
Click next and then press finish.
Now your app will be build, wait and then Continue Your project will look like this-
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizZZ_KPLHMntRWyeg6Bzjn8apmyMhsYJYEjK0_RWWvS1h4g6qVIYmKEykBcVpPHowp6XizC9jM93Fi_cewcH7zco8h5ULSZ2hW9toEpQMsn8x_GPjvHPYS9Ln3VK2jPHuI8yMYO1Fp3dw/s640/Capture1.PNG)
layout named as content_main.xml is the layout which will be shown first when you open your app
You can either edit this layout or create a new layout and call that layout using savedinstance ==null as the first layout.
Firstly edit your content_main.xml by removing tools:showIn="@layout/app_bar_main" this line and edit the app_bar_main.xml as follows-
we have added Framelayout So that each fragment would be replaced by other
Here what we want to do is open new fragment everytime the user selects an option from navigation drawer.
we have added Framelayout So that each fragment would be replaced by other
create a new layout named as lay1.xml as follows-
Now we will create a new class that will extend Frgaments and will use this new lay1.xml as its View
Create new class named as Frag1.Java-
Similarly create other layout like,lay1.xml and also create seperate Fragment Class like Frag1.Java
Now call this fragment using getSupportFragementManager() Method in MainActivity or any other desired place-
Check its .apk
get the whole project
here
Comment or send your feedback for more codes.
Click next and then press finish.
Now your app will be build, wait and then Continue Your project will look like this-
layout named as content_main.xml is the layout which will be shown first when you open your app
You can either edit this layout or create a new layout and call that layout using savedinstance ==null as the first layout.
Firstly edit your content_main.xml by removing tools:showIn="@layout/app_bar_main" this line and edit the app_bar_main.xml as follows-
we have added Framelayout So that each fragment would be replaced by other
Here what we want to do is open new fragment everytime the user selects an option from navigation drawer.
we have added Framelayout So that each fragment would be replaced by other
create a new layout named as lay1.xml as follows-
Now we will create a new class that will extend Frgaments and will use this new lay1.xml as its View
Create new class named as Frag1.Java-
Similarly create other layout like,lay1.xml and also create seperate Fragment Class like Frag1.Java
Now call this fragment using getSupportFragementManager() Method in MainActivity or any other desired place-
Check its .apk
get the whole project
here
Comment or send your feedback for more codes.
No comments:
Post a Comment