Android: NavigationDrawer/multiple activities/same menu

后端 未结 4 549
情深已故
情深已故 2020-12-12 19:56

What I am trying to do, is have a NavigationDrawer menu like this: NavigationDrawer

I\'ve figured out how to change layouts when menu items are clicked, but how do I

4条回答
  •  佛祖请我去吃肉
    2020-12-12 20:23

    If you start a new activity, you will lose your menu because the new activity will cover the old activity. You need to use fragments for this. Think of fragments as activities that can live within another activity.

    Use fragments, but add your UI elements to the activity layout outside of the FrameLayout (id: content_frame), then when you click on a menu item, your fragment transaction will only affect the content_frame FrameLayout, leaving all other layout items in place.

    Hang in there, buddy, it only gets clearer from here... until you hit the next wall :D

    I suggest this tutorial: https://www.udacity.com/course/viewer#!/c-ud853/l-1395568821

    And this material: http://developer.android.com/training/implementing-navigation/nav-drawer.html

提交回复
热议问题