[英]Android NavigationDrawer in multi module project
I have multiple modules in my project for example: 例如,我的项目中有多个模块:
app // this is the main app module app //这是主要的app模块
settings 设定
login 登录
places 地方
etc. 等等
How to use a navigation drawer in my project? 如何在我的项目中使用导航抽屉? I don't want to write the navigation drawer code in every module.
我不想在每个模块中编写导航抽屉代码。
I tried that in my app module I start an another module with startActivityForResult() method, but if the user would like to go from this module to another I finish the current method and start the second module from the app module. 我尝试在我的应用程序模块中使用startActivityForResult()方法启动另一个模块,但是如果用户希望从该模块转到另一个模块,则可以完成当前方法并从应用程序模块中启动第二个模块。 But this is not so good because the user see the app module view for a while...
但这不是很好,因为用户会看到应用模块视图一段时间。
You can to render your navigational drawer in main activity and draw screens in fragments. 您可以在主要活动中渲染导航抽屉,并在片段中绘制屏幕。 Or You can move your navigation drawer in a separate module and use it in other places in your code.
或者,您可以将导航抽屉移动到单独的模块中,然后在代码中的其他位置使用它。
From architecture approach, the drawer should be in presentation layer (app module) however you could separate it somewhere else and use callbacks to tell the presentation layer what it should do when an item is clicked. 从体系结构的角度来看,抽屉应该位于表示层(应用程序模块)中,但是您可以将其分隔在其他位置,并使用回调函数来告诉表示层单击某个项目时应该做什么。
however, I would have keep it in the app module because that module could depend on all the other modules but not the other way around. 但是,我会将其保留在app模块中,因为该模块可能依赖于所有其他模块,而不是其他方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.