나는이 응용 프로그램을 찾아서 갑자기 ClassCastException : android.widget.ImageButton으로 인해 충돌이 발생합니다. 내가 일하는 것과하지 않은 것 사이의 유일한 변화는 단색에서 드로어 블 (패턴이있는 파란색)까지 상대적인 레이아웃에 대한 배경이었습니다.receiving ImageButton에 의한 클래스 캐스트 예외
XML 파일 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical" >
<include
android:id="@+id/linearLayout1_ref"
android:layout_width="match_parent"
android:layout_height="75dip"
layout="@layout/title_area" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/fur" >
<View
android:id="@+id/view5"
style="@style/BlueBandHor"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<View
android:id="@+id/view3"
style="@style/BlueBandVer"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/view5"
android:layout_centerVertical="true" />
<View
android:id="@+id/view4"
style="@style/BlueBandVer"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/view5"
android:layout_centerVertical="true" />
<View
android:id="@+id/view1"
style="@style/BlueBandHor"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="48dp" />
<ImageButton
android:id="@+id/btn1"
style="@style/Image"
android:layout_below="@id/view5"
android:layout_centerHorizontal="true"
android:contentDescription="@string/portrait"
android:onClick="onButtonClick"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:src="@drawable/orionhead"
android:background="@drawable/button_active"
android:clickable="true"/>
<ImageButton
android:id="@+id/btn3"
style="@style/Image"
android:layout_toRightOf="@+id/view3"
android:contentDescription="@string/portrait"
android:onClick="onButtonClick"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:src="@drawable/stonewallhead"
android:background="@drawable/button_active"
android:clickable="true"
android:layout_centerVertical="true"/>
<Button
android:id="@+id/how_tobtn"
style="@style/HowTo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/view1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dip"
android:background="@drawable/howto_button_active"
android:padding="5dip"
android:text="@string/How_to"
android:textColor="@color/yellow"
android:textSize="25dip"
android:onClick="onButtonClick"/>
<ImageButton
android:id="@+id/btn2"
style="@style/Image"
android:layout_toLeftOf="@+id/view4"
android:contentDescription="@string/portrait"
android:onClick="onButtonClick"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:src="@drawable/truffelhead"
android:background="@drawable/button_active"
android:clickable="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
자바 파일 : 문제가 무엇인지의
public class ImageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
public void onClick(View view)
{Intent intent;
switch (view.getId()) {
case R.id.how_tobtn:
intent = new Intent(this, Howbtn.class);
break;
case R.id.btn1:
intent = new Intent(this, Btn1.class);
break;
case R.id.btn2:
intent = new Intent(this, Btn2.class);
break;
default:
intent = new Intent(this, Btn3.class);
break;
}
어떤 아이디어? 어떤 도움을 주셔서 감사합니다.
스택 트레이스를 표시하십시오. –