Reputation: 2323
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>
thanks for helping!
Upvotes: 3
Views: 5628
Reputation: 1
I did a RelativeLayout
with my items, and the include inside NavigationView
.
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="@color/fundo_app"
tools:visibility="visible">
<include layout="@layout/navigation_view"/>
</android.support.design.widget.NavigationView>
Upvotes: 0
Reputation: 5470
Your included layout declares a second android.support.v4.widget.DrawerLayout
, it shouldn't. Just declare a ListView
in your included layout.
File 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"
/>
Upvotes: 4