XML : Error occurs when drawerlayout is used

A list view is used in drawerlayout then the default view(the listview and also the button) cannot be clicked.

  <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical"  tools:context=".ModuleActivity">          <include layout="@layout/custom_toolbar"/>        <RelativeLayout          android:layout_width="match_parent"          android:layout_height="match_parent"  >            <Button              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:text="New Button"              android:id="@+id/button"/>            <ListView              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:id="@+id/lv_module"              android:layout_below="@+id/button"/>            <include layout="@layout/custom_drawerlayout" />              </RelativeLayout>    </LinearLayout>    

-----------above is the activity layout

-----------below is the drawerlayout named custom-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/dl_left"      android:layout_width="match_parent"      android:layout_height="match_parent">        <LinearLayout          android:layout_width="match_parent"          android:layout_height="match_parent">          <ImageView              android:id="@+id/iv_main"              android:layout_width="100dp"              android:layout_height="100dp" />      </LinearLayout>        <LinearLayout          android:layout_width="match_parent"          android:layout_height="match_parent"          android:background="#fff"          android:layout_gravity="start">          <ListView              android:id="@+id/lv_left_menu"              android:layout_width="match_parent"              android:layout_height="match_parent"              android:divider="@null"              android:text="DrawerLayout" >              </ListView>      </LinearLayout>  </android.support.v4.widget.DrawerLayout>    

Firstly i thought it may be caused by conflict between two onItemClickListeners, but latter i find it can even not be clicked. So i added a button to test the case. Well, the button can not be clicked neither.

Above all i conclude that it is because of the unsuitable code of drawerlayout.

Really confused...

No comments:

Post a Comment