[英]Drawer, Fragment and Activities
I have some questions about designing applications with NavigationDrawer
. 我对使用NavigationDrawer
设计应用程序有一些疑问。
I create an application with NavigationDrawer
composed of one Activity
and some Fragment
s. 我用NavigationDrawer
创建一个由一个Activity
和一些Fragment
组成的应用程序。 For example I have four Fragment
s, and every Fragment
has some actions. 例如,我有四个Fragment
,每个Fragment
都有一些动作。
Which is the correct way to implement that? 哪种是正确的实现方式?
Activity
? 将所有操作添加到我的Activity
? MainActivity
with context/view? 创建其他一些类并使用上下文/视图从MainActivity
调用它们? Any information about these questions is really appreciated. 关于这些问题的任何信息都非常感谢。 I also need some example or resource explaining which is the correct way to implement this. 我还需要一些示例或资源说明,这是实现此目标的正确方法。
Anyone can help? 有人可以帮忙吗?
Check the google IO 2014 source code to get a good idea of the nav drawer implementation 查看Google IO 2014源代码,以了解导航抽屉的实现
https://github.com/google/iosched https://github.com/google/iosched
All the navigation and fragment transactions should be done via the Main Activity or the activity holding the fragments. 所有导航和片段事务都应通过主活动或包含片段的活动来完成。 Any kind of fragment - fragment communication should be avoided. 任何类型的片段-片段通信都应避免。 The developer docs shows a good example of how to handle fragment communication via Activity using interfaces 开发人员文档显示了一个很好的示例,说明了如何使用接口通过Activity处理片段通信
http://developer.android.com/training/basics/fragments/communicating.html http://developer.android.com/training/basics/fragments/communicating.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.