把他们一个滚动视图里面后的错误访问复选框 [英] Error accessing checkboxes after putting them inside a scrollview

查看:110
本文介绍了把他们一个滚动视图里面后的错误访问复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了我的XBL从仅仅有复选框中的布局,以他们在一个滚动视图之中。这样我可以添加更多不打扰用户提供了一个选项页。当我这样做,我得到了以下错误: http://pastebin.com/T5hZHRxu

下面是已更改的XML部分:

 <查看
    机器人:ID =@ + ID /视图2
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =1DP
    机器人:layout_above =@ + ID / scrollbox1
    机器人:layout_alignLeft =@ + ID / textView4
    机器人:layout_alignRight =@ + ID / num_input
    机器人:layout_marginBottom =14dp
    机器人:背景=#808080/>
<滚动型
机器人:ID =@ + ID / scrollbox1
机器人:layout_width =match_parent
机器人:layout_height =55dp
机器人:layout_above =@ + ID /厂景>
    < TableLayout
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:stretchColumns =1>
        <复选框
        机器人:ID =@ + ID /环己烷
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ CB/>
        <复选框
        机器人:ID =@ + ID / chex2
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginBottom =28dp
        机器人:文字=@字符串/ AC/>  < / TableLayout>< /滚动型><查看
    机器人:ID =@ + ID /厂景
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =1DP
    机器人:layout_above =@ + ID / aboutButt
    机器人:layout_alignLeft =@ + ID / aboutButt
    机器人:layout_alignRight =@ + ID /视图2
    机器人:layout_marginBottom =14dp
    机器人:背景=#808080/>


解决方案

有时,当您更改/添加XML文件和/或查看你会得到这个有趣的 ClassCastException异常错误。编辑只是没有意识到自己已经被适当地改变。清洁项目允许Eclipse通过排序的变化,我想你可以说。它重建项目,以便Eclipse可以看什么是什么,这里的一切。

基本上,如果你得到一个有趣的错误是这样,比如它说,它不能撒开查看到另一个当你知道你是不是要投它,首先要做的就是清理项目

项目 - >清理 - >选择您的项目清理

下面是一个SO帖子可以解释它更好的。

I changed my xbl from just having checkboxes in the layout to them being in a scrollview. That way I can add more without troubling users with an options page. When I do this I get the following error: http://pastebin.com/T5hZHRxu

Here is the xml part that was changed:

<View
    android:id="@+id/view2"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_above="@+id/scrollbox1"
    android:layout_alignLeft="@+id/textView4"
    android:layout_alignRight="@+id/num_input"
    android:layout_marginBottom="14dp"
    android:background="#808080" />
<ScrollView
android:id="@+id/scrollbox1"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_above="@+id/view1" >
    <TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1">
        <CheckBox
        android:id="@+id/chex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/cb" />
        <CheckBox
        android:id="@+id/chex2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="28dp"
        android:text="@string/ac" />

  </TableLayout>

</ScrollView>

<View
    android:id="@+id/view1"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_above="@+id/aboutButt"
    android:layout_alignLeft="@+id/aboutButt"
    android:layout_alignRight="@+id/view2"
    android:layout_marginBottom="14dp"
    android:background="#808080" />

解决方案

Sometimes when you change/add xml files and/or Views you will get this funny ClassCastException error. The editor just doesn't realize that they have been changed appropriately. Cleaning the project allows Eclipse to "sort through" the changes, I guess you could say. It rebuilds the project so Eclipse can "see" what is what and where everything is.

Basically, if you get a funny error like this, such as it saying it can't cast one View to another when you know you aren't trying to cast it, first thing to do is to clean the project

Project --> Clean --> Choose your project to clean

Here is a SO post that may explain it better

这篇关于把他们一个滚动视图里面后的错误访问复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆