Reputation: 51
I got an IAE when copying the SlidingDrawer code from Android SDK and importing it into my project.
java.lang.IllegalArgumentException: The handle attribute is required and must refer to a valid child.
This is my layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MySlidingDrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="test only"
android:textSize="20dp" />
<com.mytest.view.SlidingDrawer
android:id="@+id/SlidingDrawer"
android:layout_width="wrap_content"
android:layout_height="250dip"
android:layout_alignParentBottom="true"
android:content="@+id/contentLayout"
android:handle="@+id/slideButton"
android:orientation="vertical"
android:topOffset="100.5dp"
android:padding="10dip" >
<Button
android:id="@id/slideButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UP" >
</Button>
<LinearLayout
android:id="@id/contentLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
<Button
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="Button01" >
</Button>
</LinearLayout>
</com.mytest.view.SlidingDrawer>
</RelativeLayout>
this is my attrs:
<declare-styleable name="SlidingDrawer">
<attr name = "orientation" format="integer"/>
<attr name = "bottomOffset" format = "dimension"/>
<attr name = "topOffset" format = "dimension"/>
<attr name = "allowSingleTap" format = "boolean"/>
<attr name = "animateOnClick" format = "boolean"/>
<attr name = "handle" format = "reference"/>
<attr name = "content" format = "reference"/>
</declare-styleable>
Upvotes: 1
Views: 886
Reputation: 995
Your problem is that you imported the class as a custom view yet you still use :
android:content="@+id/contentLayout"
android:handle="@+id/slideButton"
Use this instead:
app:content="@+id/contentLayout"
app:handle="@+id/slideButton"
Upvotes: 0
Reputation: 1264
check this Link. I think you have to declare your own name space to refer the Handler http://chrisharrington1.wordpress.com/2012/02/06/android-modifying-the-slidingdrawer-widget-to-use-a-max-height/
Upvotes: 0
Reputation: 207
Ok, this is an issue so it's not your problem.
http://code.google.com/p/android/issues/detail?id=3162
i think that's why the sliding drawer is deprecated on API level 17.
Upvotes: 2
Reputation: 38605
EDIT:
On your Button, try changing android:id="@id/slideButton"
to android:id="@+id/slideButton"
The View that acts as the handle for your sliding drawer needs to have android:id="@id/handle" for SlidingDrawer to work
Upvotes: 0