本文介绍了与抽屉式导航栏的布局包括布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我的问题其实很简单,但我无法弄清楚如何解决它。
一个与此code工作导航抽屉:
i think my problem is actually quite simple, but i can't figure out how to solve it.a have a working navigation drawer with this code:
<?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>
但是当我尝试做使用包括这样的:
but when i try do use include like this:
<?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>
没有任何反应,当我在我的列表视图我的框架布局中的项点击。
nothing happens when i click on the items of my list view within my frame layout.
这是抽屉布局我试图包括:
this is the drawer layout i'm trying to 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" >
<!-- 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>
感谢您的帮助!
推荐答案
您包括布局声明第二 android.support.v4.widget.DrawerLayout
,它不应该。就在您的布局包含一个声明的ListView
。
Your included layout declares a second android.support.v4.widget.DrawerLayout
, it shouldn't. Just declare a ListView
in your included layout.
文件 drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
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"
/>
这篇关于与抽屉式导航栏的布局包括布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!