Android中的奇怪ClassCastException

时间:2015-12-26 14:29:27

标签: android button imageview classcastexception

尝试在Android中查找Button时,我遇到了一个奇怪的ClassCastException。 ID完全连接到Button,没有ImageView具有相同的ID

Logcat输出

12-26 14:10:24.325: E/AndroidRuntime(1307): FATAL EXCEPTION: main
12-26 14:10:24.325: E/AndroidRuntime(1307): java.lang.ClassCastException:       android.widget.ImageView cannot be cast to android.widget.Button
12-26 14:10:24.325: E/AndroidRuntime(1307):     at com.appstasy.appprototype.MainActivity.updateUi(MainActivity.java:212)

MainActivity第212行

Button button = (Button) findViewById(R.id.mehr);

我的布局有2500行,所以我只会发布带有我想要访问的按钮的部分 所有其他布局不包含id“mehr”

tab1.xml

           <Button
            android:id="@+id/mehr"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/favo49"
            android:layout_marginTop="30dp"
            android:onClick="loadMore"
            android:text="GIB MIR MEHR"
            android:textSize="15sp"
            android:visibility="gone" >
            </Button>

0 个答案:

没有答案