SlidingDrawer 运行正常但布局里面出现IllegalArgumentException: The handle attribute is required and must refer to a valid child。
代码如下。程序运行的时候很正常,只是布局的时候layout出现以上的异常,xml里面的代码正常。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/FrameLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#66ff66">
<Button android:text="@+id/Button01" android:id="@+id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<TextView android:text="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/tv"
android:scrollY="100dip" android:textColor="#ff0000"
android:layout_marginTop="100dip"></TextView>
<SlidingDrawer android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/drawer"
android:content="@+id/content" android:handle="@+id/handle">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/handle"
android:background="@drawable/btn_dropdown_normal"></ImageView>
<FrameLayout android:id="@+id/FrameLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#66ff66">
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/icon"></ImageView>
<ImageView android:id="@+id/ImageView02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/icon"></ImageView>
<ImageView android:id="@+id/ImageView03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/icon"></ImageView>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:orientation="vertical">
<Button android:text="@+id/Button02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/content_button"></Button>
<EditText android:text="@+id/EditText01"
android:layout_height="wrap_content" android:id="@+id/content_et"
android:layout_width="fill_parent"></EditText>
</LinearLayout>
</FrameLayout> </SlidingDrawer>
</FrameLayout>

解决方案 »

  1.   

    <SlidingDrawer android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:id="@+id/drawer"
    android:content="@+id/content" android:handle="@+id/handle">
    注意红色和蓝色的部分,这两个id不是白给的,是需要你指定被控制的布局,比如你的SlidingDrawer拉开之后里面有一个LinearLayout,那LinearLayout的里就应该加一句android:id="@id/content"
      

  2.   

    android:content="@+id/content" android:handle="@+id/handle">
    一个对应内容,一个对应向上向下向左向右的箭头或者其他