在使用安卓的抽屉控件DrawerLayout的时候有这样的一个需求,就是在某些状态下抽屉上的布局是列表
left_drawer有些状态下是列表left_drawer1两个列表样式不一样。因此我的布局文件就写成这个样子如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff"
android:orientation="vertical" >
<android.support.v4.widget.DrawerLayout
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" >
<TextView
android:id="@+id/tv_sidebar_tip"
android:layout_width="@dimen/contacts_main_sidebar_tipbox_size"
android:layout_height="@dimen/contacts_main_sidebar_tipbox_size"
android:layout_gravity="center"
android:background="#C1F1FD"
android:gravity="center"
android:textColor="@color/blue"
android:textSize="@dimen/common_textsize_xxl"
android:textStyle="bold"
/>
</FrameLayout>
<com.diegocarloslima.fgelv.lib.FloatingGroupExpandableListView
android:id="@+id/left_drawer"
android:layout_width="@dimen/contacts_main_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="#ffffffff"
android:cacheColorHint="@android:color/transparent"
android:childDivider="#00000000"
android:choiceMode="singleChoice"
android:divider="#00000000"
android:dividerHeight="1dp"
android:visibility="gone"
android:scrollbars="@null" />
<ExpandableListView
android:id="@+id/left_drawer1"
android:layout_width="@dimen/contacts_main_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="#ffffffff"
android:cacheColorHint="@android:color/transparent"
android:childDivider="#00000000"
android:choiceMode="singleChoice"
android:divider="#00000000"
android:dividerHeight="1dp"
android:scrollbars="@null"
android:visibility="gone" >
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
然后在代码中控制两个列表的显示和隐藏。结果在隐藏left_drawer显示left_drawer1的时候,加载显示都是没问题的。但是在关闭抽屉却会报出标题上的那个异常问题。而一个列表是正常的。因此 我想导致这个错误应该是DrawerLayout的抽屉布局里面不支持两个列表导致。