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

在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书童
    迷途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书童
    迷途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 条评论 ---
    • 迷途d书童你对比下我上面贴的代码,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!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值