我觉得我的问题其实很简单,但是我无法解决它。 我有一个工作中的导航抽屉,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:padding="5dp" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/category_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</FrameLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:entries="@array/features"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:choiceMode="singleChoice"
android:divider="@null"
android:background="#E0E0E0"
android:dividerHeight="0dp"
/>
</android.support.v4.widget.DrawerLayout>
但是当我尝试像这样使用include时:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:padding="5dp" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/category_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</FrameLayout>
<!-- The navigation drawer -->
<include layout="@layout/drawer"/>
</android.support.v4.widget.DrawerLayout>
当我在我的框架布局中点击列表视图项时,没有任何反应。
这是我尝试包含的抽屉式布局:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:padding="5dp" >
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:entries="@array/features"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:choiceMode="singleChoice"
android:divider="@null"
android:background="#E0E0E0"
android:dividerHeight="0dp"
/>
</android.support.v4.widget.DrawerLayout>
感谢您的帮助!