【发布时间】:2015-05-14 05:32:44
【问题描述】:
我查看了其他类似的帖子,但找不到解决方案。我在调用getActionBar() 时遇到了空指针问题,我似乎已经通过使用getSupportActionBar() 解决了这个问题。我的应用程序现在运行,但我的导航抽屉没有打开。
这是我的基本活动,所有其他活动都扩展了这个基本活动:
* This activity will add Navigation Drawer for our application and all the code related to navigation drawer.
* We are going to extend all our other activites from this BaseActivity so that every activity will have Navigation Drawer in it.
* This activity layout contain one frame layout in which we will add our child activity layout.
*/
这是 BaseActivity 视图的 XML:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:theme="@android:style/Theme.WithActionBar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#888888"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
我的 minSdkVersion 是 16,我使用的是标准 @style/AppTheme,它使用 Theme.AppCompat.Light 作为其父级。
代码运行良好,没有错误,但导航抽屉无法打开。
非常感谢任何帮助,在此先感谢!
【问题讨论】:
-
您的 LogCat 中有任何错误消息吗?
-
@Elenasys 一点也不,应用程序编译并运行良好,我只是无法打开抽屉。
-
Ok!,你是想滑动打开菜单吗?或单击菜单的某些元素?
-
@Elenasys 我正在尝试两者,我尝试将其滑出并单击操作栏左侧顶部的