Skip to content Skip to sidebar Skip to footer

Android Navigation Drawers And Fragments

I have just created a new project using Eclipse and the Android SDK. The project now contains a blank activity with navigation drawers and its sample 3 navigation items. Under res/

Solution 1:

Create new layout for each Fragment items if Fragment views are different

When an drawer item is selected, replace the fragment in the activity.

So your activity layout should have , Drawer as parent layout and a FrameLayout container and ListView as child.

When an item is selected, replace the Fragment in the container of Activity Layout

Solution 2:

If you want the layout to be the same you don't have to replace fragment_main.xml because that's your layout file for your fragment. If your layout is different in each fragment. You have to create a different layout file and load it with your Fragment class.

But again if your layout of the fragments is the same you just have to "refill" your fragment_main.xml with new content.

I hope i cleared it a bit up for you

Post a Comment for "Android Navigation Drawers And Fragments"