如何在Android中的片段上创建导航抽屉 [英] How to create a navigation drawer on a fragment in android

查看:59
本文介绍了如何在Android中的片段上创建导航抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设计中需要一些建议.我有一个Activity类,可以加载多个片段.片段之一具有导航抽屉.当用户单击导航列表中的任何项目时,它将加载其片段,并具有一个后退按钮,可通过导航抽屉返回到片段. 如图中所示. A,B,C是导航抽屉中的项目,它将替换内容,并具有一个后退按钮,可使用导航抽屉返回到片段D. 我看过多个教程,它们在活动中加载了导航抽屉,并将导航作为主要内容.我想要的是,如果用户单击顶部的图标,它将显示列表.它可以成为Fragment D布局的一部分吗?

有什么建议值得赞赏吗?

解决方案

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

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

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.

这篇关于如何在Android中的片段上创建导航抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆