Android Navigation Drawer

Android Navigation Drawer - Hello friends Android tutorial and tips trik, The article you are reading this time with the title Android Navigation Drawer, we have prepared this article for you to read and download the information therein. hopefully fill posts article android, article Drawer, article Navigation, article Tutorial, we can write this you understand. Well, happy reading.

Title : Android Navigation Drawer
link : Android Navigation Drawer

Baca juga


Android Navigation Drawer

Hello everyone welcome to backbencherscoding.

In this Android tutorial we will see how to make navigation drawer.

So lets begin.

Start a new Android studio project Give it a name Android_Nav give it a company domain and a project location Click on NextClick on phone and tablet and next Now here select Navigation Drawer activity.

Clickon Next and click on Finish So now that our project has been launched let's start our virtual device.

Go to tools->Android->AVD manager and click on this play button.

Onrunning our application here we get our navigation drawer which has items-Import,Gallery, Slideshow and Tools.

We are going to modify these items on clicking theseitems,here now we can see they are connected to a single page.

What we'regoing to do is we are going to make separate fragments for each item so now let us make our firstfragment.

Go to package click on new fragment->fragment(blank) give it a name Fragment_Home since is our first item.

Modify the XML file nameuncheck the check boxes and click on Finish so now we see the XML file and the java file of our home fragment.

Let us modify the XML file make layout_width as wrapcontent, height also as wrapcontent.

The text as Home Page.

Give it a textsize as 25sp(scale independent pixel)give it a layout_gravity as center and we are done with the XML page.

similarly I'm going to create anotherfragment three more fragments for "About" "Gallery" and "Contact" items.

So nowI have created three more fragments.

Fragment "About" and I have modified its XML and written its text as "About Page".

Similarly for "Gallery" and for fragment "Contact".

Now we go to app_bar_main.

Xml in layout folder.

In this, what we're goingto do is we are going to delete this line and delete content_main.

Xmland create a FrameLayout.

In this FrameLayout we are going to embed the fragments.

Give the FrameLayout width as matchparent Height also as matchparent and give it an id as main_container.

So this is a FrameLayout id which we are going to use later and now after this,we are going to go to activity_main_drawer.

Xml in themenu folder and change the item IDs and the item title as nav_home for our first item and change its title to "Home" Second nav_about and change its title to "About".

Third for "Gallery".

This will change the items in the Navigation Drawer And last for contact And changeits title to contact so now when we look at the navigation drawer,it will show us these four items.

Now we go to the MainActivity.

Java And change theirIDs there as well first was nav_home,second was nav_about,third was nav_gallery and last was nav_contact.

So after this, we're going to docoding in the onCreate method() After setContentView() we are going to create a fragment home object like this FragmentHome and give it a name fragmenthome = new FragmentHome(); and FragmentTransition object and now we are going to call getSupportFragmentManager(),which returns the object of FragmentManager and using this we are going to call beginTransaction() method This begin transaction method returns the object of FragmentTransaction and here we are going to use that object to call the replace() method in which we are going to pass the ID of the FrameLayout R.

Id.

Main_container and fragment_home abject like this and now we are going to call the commit() method to save all of this and now we are going to copy this entirecode and paste it down in onNavigationItemSelected() function below these IDs where we are given this.

For home it should be this way itself For "About" we will vary the objects.

Fragment_About.

change the object name as well.

fragment_about Fragment_About and copy this object and paste it over here Similarly copy this code again, paste it in your gallery as well as in your Contact and change the objects as I have shown you in the about fragment.

So now I have changed the objects for the galley and Contact as well so now we are going to run this and we are done coding.

So here is our output.

We can see a navigation drawer over here And on clicking this we willsee our fragments and their titles For gallery it will show "Gallery page" and last for contact it will show "Contact Page" so if you like this video please subscribe and share thank you for watching.



Thus Article Android Navigation Drawer

That article Android Navigation Drawer This time, hopefully we can give you all of the benefits. Well, I'll see you in another article post.

You now read the article Android Navigation Drawer the link address http://svedda79.blogspot.com/2016/01/android-navigation-drawer.html

0 Response to "Android Navigation Drawer"

Post a Comment