且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Android中的片段上创建导航抽屉

更新时间:2023-01-10 10:30:57

您将必须创建一个其中包含导航抽屉的类,然后您可以将特定的类扩展到您想要的任何位置....如果您愿意然后将其放在片段上,然后扩展特定的活动,并通过导航抽屉将这些片段保存在该类中.

否,要替换片段的活动应该具有导航抽屉.

I need some suggestions in my design. I have an Activity class that loads multiple fragments. One of the fragment has Navigation drawer. When the user clicks any of the items in the navigation list it loads its fragments and has a back button to come back to the Fragment with the navigation Drawer. As shown in the image. A,B, C are items in navigation drawer which would replace the content and has a back button to go back to Fragment D with navigation drawer. I have seen multiple tutorials that load navigation drawer in activity and has navigation as main content. What I want is if the use clicks the icon on top it shows the list. Can it be part of the Fragment D layout ?

Any suggestions are appreciated?

You will have to make a class which is having a navigation drawer in it and then you can extend the particular class wherever you want .... if u want it on fragments then just extend that particular activity holding those fragments with that class with navigation drawer.

No,the activity on which you are replacing fragments should have navigation drawer.that is it.