user3710994
user3710994

Reputation: 1

Multipe List views in Drawer layout in Android

I am using a custom list view to display data in my app, Then i tried to add navigation drawer

Clicks on drawer layout doesnt work. It end up opening the custom list view as it is behind the drawer list view. Drawer list view never gets focus, Even when the drawer is opened

Below is my main activity xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:focusable="true"/>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:focusableInTouchMode="true"
android:focusable="true"
android:descendantFocusability="blocksDescendants"/>
</android.support.v4.widget.DrawerLayout>
<ListView
android:id="@+id/listScreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="7dp">
</ListView>
</RelativeLayout>

Upvotes: 0

Views: 334

Answers (2)

user3710994
user3710994

Reputation: 1

<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" >

 <include layout="@layout/activity_main" />

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:focusable="true"/>
<ListView
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp"/>


</android.support.v4.widget.DrawerLayout>

Upvotes: 0

RuNo280
RuNo280

Reputation: 583

Use this way :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<include layout="@layout/actionbar" />

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- The main content view -->

    <include layout="@layout/activity_main" />

    <!-- The navigation drawer -->

    <include layout="@layout/drawer_layout_right" />

    <include layout="@layout/drawer_layout_left" />
</android.support.v4.widget.DrawerLayout>

drawer_layout_right.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:orientation="horizontal" >

<ListView
    android:id="@+id/lv1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none" />

</LinearLayout>

drawer_layout_left.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:orientation="vertical" >

<ListView
    android:id="@+id/lv2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none" />

</LinearLayout>

Upvotes: 8

Related Questions