Android的导航抽屉和片段 [英] Android Navigation Drawers and Fragments
问题描述
我刚刚创建使用Eclipse和Android SDK的一个新项目。该项目现在包含导航抽屉和样品3导航项目的空白活动。
在 RES /布局
,我现在有 activity_main.xml中
, fragment_main.xml
和 fragment_navigation_drawer.xml
。
我的问题是 - 依据又是什么在导航抽屉选择显示不同的内容,我做这将代替 fragment_main.xml $ C $的加载一个新的观点C>,还是我加载
fragment_main.xml
?
每个片段
项目创建新的布局,如果片段意见
是不同的。
当选择了一个抽屉里的项目,替换活动的片段。
所以,你的活动布局应该有,抽屉父布局
和的FrameLayout容器
和的ListView
的孩子。
当一个项目被选中,替换片段
在活动布局的容器
I have just created a new project using Eclipse and the Android SDK. The project now contains a blank activity with navigation drawers and its sample 3 navigation items.
Under res/layout
, I currently have activity_main.xml
, fragment_main.xml
and fragment_navigation_drawer.xml
.
My question is -- to display different content based on what is chosen in the navigation drawer, do I make a new view that will be loaded in place of the fragment_main.xml
, or do I load the view inside of fragment_main.xml
?
Create new layout for each Fragment
items if Fragment views
are different
When an drawer item is selected, replace the fragment in the activity.
So your activity layout should have , Drawer as parent layout
and a FrameLayout container
and ListView
as child.
When an item is selected, replace the Fragment
in the container of Activity Layout
这篇关于Android的导航抽屉和片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!