【发布时间】:2015-09-11 15:38:32
【问题描述】:
我是 Android 新手,并通过以下方式学习在 Android 中创建片段
例如:Fragment Navigation Drawer在菜单项之间导航和添加导航标题之间的代码包含一个方法
getActivity()。由于作者没有提到将这段代码粘贴到哪里,我粘贴在我的
MainActivity.java文件中我是否将在菜单项之间导航和添加导航标题之间的代码粘贴在正确的位置?
在方法
selectDrawerItem(MenuItem menuItem)中有一条注释// Create a new fragment and specify the planet to show based on position
作者是否希望我在这里添加一些内容。- 我在AndroidStudio上创建的项目文件布局如下:AndroidStudio Snapshot
【问题讨论】:
-
getActivity() 通常在片段内调用。
标签: android android-fragments navigation-drawer