Same Navigation Drawer in different Activities

前端 未结 12 1587
执念已碎
执念已碎 2020-11-22 04:24

I made a working navigation drawer like it\'s shown in the tutorial on the developer.android.com website. But now, I want to use one Navigation Drawer, i created in the Navi

12条回答
  •  梦如初夏
    2020-11-22 05:28

    Create Navigation drawer in your MainActivity using fragment.
    Initialize the Navigation Drawer in MainActivity
    now in all other activities you want to use same Navigation Drawer put DrawerLayout as base and fragment as navigation drawer. Just set android:name in your fragment pointing to your fragment Java file. You won't need to initialize the fragment in other Activities.
    You can access Nav Drawer by swipe in other activities like in Google Play Store app

提交回复
热议问题