您的位置:首页 > Web前端

SlidingDrawer ID引发的错误 ava.lang.IllegalArgumentException: The handle attribute is must refer to a

2012-10-18 10:07 591 查看
在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.

哪位大神帮看看呀!

标签:Android SDK

我想问同样的问题共1个人想要问同样的问题补充话题说明»

分享到

收藏

0

举报

踩0|
顶0

按评价排序 |显示最新答案 | 回页面顶部共有6个答案

我要回答»





迷途d书童 回答于 2012-02-29 10:42

举报
上面布局文件少了一个
LinearLayout的结束标签


有帮助(0) |没帮助(0) |评论(0) |
引用此答案





叶的旺旺 回答于 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没做修改

有帮助(0) |没帮助(0) |评论(0) |
引用此答案





迷途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。

有帮助(0) |没帮助(0) |评论(0) |
引用此答案





叶的旺旺 回答于 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>

却正常运行

--- 共有 1 条评论 ---



你对比下我上面贴的代码,ImageView和LinearLayout是不是包含在SlidingDrawer里面。(7个月前
by 迷途d书童)

有帮助(0) |没帮助(0) |评论(1) |
引用此答案





叶的旺旺 回答于 2012-02-29 12:38

举报
已检查出来,第一个SlidingDrawer中,应该是<SlidingDrawer > 而不是<SlidingDrawer/>

有帮助(0) |没帮助(0) |评论(0) |
引用此答案





雨焰 回答于 2012-04-04 14:41

举报

你多写了一个命名空间-xmlns

在你的第二个linearlayout中不用再写xmlns!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐