简体   繁体   English

Android导航抽屉

[英]Android Navigation Drawer

通过多个活动或在片段的帮助下实现导航抽屉的最佳方法是什么。目前,在多个活动的帮助下,这种正确的做法是吗?

You should use Fragments for android. 您应该为Android使用Fragments。 Its the best way. 这是最好的方法。 If you use Fragments you do not have to write the code for providing the functionality of Navigation. 如果使用片段,则不必编写代码来提供导航功能。 Its the most recommended way in android for navigation. 它是android中最推荐的导航方式。 Refer the docs . 请参阅文档

Navigation Drawer with Fragments is the most recommended approach. 带有片段的导航抽屉是最推荐的方法。 It provides lot of flexibility rather than activity. 它提供了很大的灵活性,而不是活动性。 I advise you to implement with Fragments. 我建议您使用Fragments实施。 If you wanna do in standard approach the Fragments are the right and the most correct way. 如果您想以标准方式进行操作,则片段是正确且最正确的方法。 Check the Design Specifications. 检查设计规格。

Try ActionBarSherlock Navigation Drawer. 尝试使用ActionBarSherlock导航抽屉。 It will work with API level 8 also. 它也将与API级别8一起使用。 So try this and this link. 因此,尝试这个这个链接。 And you have to work with fragments rather than Activities. 而且您必须使用片段而不是活动。

I think I know the problem you are facing and I recommend you to check out this article I've written about the Nav Drawer navigation . 我想我知道您面临的问题,建议您阅读我写的有关Nav Drawer导航的这篇文章

When you have clear on which places you are showing the Drawer then the best way to implement it is using the Android Support Design Library . 当您确定要在哪个位置显示抽屉时,实现它的最佳方法是使用Android支持设计库

When you have different activities where you are showing the Drawer (this could be different hierarchy levels in your app) you'll have to create/reuse a new Drawer on that activity that knows on which activity is in to show as selected that entry on the Drawer. 当您有不同的活动要显示抽屉时(这可能是应用程序中的不同层次结构级别),您将不得不在该活动上创建/重用一个新的抽屉,该抽屉知道要在哪个活动中显示为选中的该条目。抽屉。

I don't know if that is exactly your question but hope so. 我不知道这是否正是您的问题,但希望如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM