NavigationDrawer与活动 [英] NavigationDrawer with Activities

查看:89
本文介绍了NavigationDrawer与活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前在我的应用我有一个抽屉式导航。当我开始做这个工作,我发现很多人习惯片段,而不是活动,但是,我需要与活动的工作,因为我意识到你不能够把片段的片段,我需要以后的发展中。

Currently in my application i have a navigation drawer. When i began working on it i discovered that many people used fragments instead of activities, however, i needed to work with activities as i realised you weren't able to put fragments within fragments which i would need later on in development.

然而,问题是,通过活动,当我点击了新的一页从导航抽屉里有不流畅的动画作为课程的活动有加载起来。

However, the issue is that by using activities, when i click on a new page from the navigation drawer there isn't a smooth animation as of course the activity has to load up again.

有没有什么解决办法?或者我应该更改与片段应用程序的工作。我发现人们做活动使用的导航抽屉的时候工作,但是我不能确定他们是否已经解决了这个问题,或者只是使用它?

Is there any solution to this? or should i change the application to work with fragments. I have found that people do work with activities when using navigation drawer however i'm unsure if they have solved this issue or just work with it?

感谢

推荐答案

在你的XML,当你创建一个 NavigationDrawer 应指定的FrameLayout (或的ViewGroup 我猜),其在本质上可视屏幕时,抽屉并不活跃。为了实际利用这一点,你必须使用你的DrawerActivity的 FragmentManager 属性交换使用片段办法出电流片段根据从抽屉中选择的列表项。 (我很抱歉,如果你已经知道了)

In your XML, when you create a NavigationDrawer you should specify a FrameLayout (or a ViewGroup I guess) that will essentially be the visible screen when the Drawer is not active. In order to actually use this, you have to use a Fragment approach by using the FragmentManager property of your DrawerActivity to swap out the current Fragment based on the list item selected from the Drawer. (I apologize if you already knew that)

虽然它不被视为最佳做法,但它是可以嵌套的片段,看到这里这里虽然你需要或者安卓4.2或支持库11,不应该是一个问题。

Although it is not considered "best practice" but it is possible to nest fragments, see here OR here although you will need either android 4.2 or support library 11 which shouldn't be an issue.

总之,没有办法用活动 s,而保持了导航抽屉,你将不得不使用片段秒。

In short, there is no way to use Activitys while maintaining the Navigation Drawer, you will have to use Fragments.

这篇关于NavigationDrawer与活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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