在xml文件中定义如下:
01 | <? xml version = "1.0" encoding = "utf-8" ?> |
02 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
03 | android:orientation = "vertical" |
04 | android:layout_width = "fill_parent" |
05 | android:layout_height = "fill_parent" |
06 | > |
07 | < SlidingDrawer |
08 | android:layout_width = "fill_parent" |
09 | android:layout_height = "fill_parent" |
10 | android:id = "@+id/sliding" |
11 | android:handle = "@+id/name" |
12 | android:content = "@+id/layout" |
13 | /> |
14 | < ImageView |
15 | android:id = "@+id/name" |
16 | android:src = "@drawable/icon" |
17 | android:layout_width = "wrap_content" |
18 | android:layout_height = "wrap_content" |
19 | /> |
20 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
21 | android:orientation = "vertical" |
22 | android:id = "@+id/layout" |
23 | android:layout_width = "fill_parent" |
24 | android:layout_height = "fill_parent" |
25 | > |
26 | |
27 | </ LinearLayout > |
Activity没做任何修改,运行后出现错误:
02-28 14:18:55.887: ERROR/AndroidRuntime(354): java.lang.RuntimeException: Unable to start activity ComponentInfo{yang.slidingdrawer03/yang.slidingdrawer03.SlidignDrawer03}: java.lang.IllegalArgumentException: The handle attribute is must refer to an existing child.
哪位大神帮看看呀!
按评价排序 |显示最新答案 | 回页面顶部共有6个答案 我要回答»
-
叶的旺旺 回答于 2012-02-29 11:52举报
不好意思,发漏了,完整代码是这样的,:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SlidingDrawer
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/sliding"
android:handle="@+id/name"
android:content="@+id/layout"
/>
<ImageView
android:id="@+id/name"
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout></LinearLayout>
还是出现上面的错误,Activity没做修改 -
迷途d书童 回答于 2012-02-29 12:03举报
01
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02
<
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
03
android:orientation
=
"vertical"
04
android:layout_width
=
"fill_parent"
05
android:layout_height
=
"fill_parent"
06
>
07
<
SlidingDrawer
08
android:layout_width
=
"fill_parent"
09
android:layout_height
=
"fill_parent"
10
android:id
=
"@+id/sliding"
11
android:handle
=
"@+id/name"
12
android:content
=
"@+id/layout"
13
/>
14
<
ImageView
15
android:id
=
"@id/name"
16
android:src
=
"@drawable/icon"
17
android:layout_width
=
"wrap_content"
18
android:layout_height
=
"wrap_content"
19
/>
20
<
LinearLayout
21
android:orientation
=
"vertical"
22
android:id
=
"@id/layout"
23
android:layout_width
=
"fill_parent"
24
android:layout_height
=
"fill_parent"
25
>
26
</
LinearLayout
>
27
</
SlidingDrawer
>
28
</
LinearLayout
>
ImageView,LinearLayout是SlidingDrawer子控件,引用SlidingDrawer的android:handle,android:content的id。
-
叶的旺旺 回答于 2012-02-29 12:16举报
奇怪的是,我写另一个布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SlidingDrawer
android:id="@+id/sd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:handle="@+id/name"
android:content="@+id/content"
>
<Button
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>却正常运行