0
ここでは、私のスクリプト(部分コード)のコードである:ここでエラーsetBackgroundResourceを使用して()
r1c1text.setOnClickListener(new OnClickListener() {
public void onClick(View v){
v.setBackgroundColor(0xff000000);
v.setBackgroundResource(R.id.xImg);
Toast.makeText(Connect.this, "" + v, Toast.LENGTH_SHORT).show();
}
});
はXMLです:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="80dip"
android:orientation="horizontal"
android:layout_below="@+id/connectImg"
>
<TextView android:id="@+id/r1c1text"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:textColor="#000000"
android:text="@string/class1"/>
<TextView android:id="@+id/r1c2text"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/r1c1text"
android:layout_marginLeft="20dip"
android:textColor="#000000"
android:text="@string/machine"/>
<TextView android:id="@+id/r1c3text"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/r1c2text"
android:layout_marginLeft="20dip"
android:textColor="#000000"
android:text="@string/ceiling"/>
</RelativeLayout>
Eclipseは私にv.setBackgroundResource(R.id.xImg);
上のエラーを与えるものではありませんが、アンドロイドは"Force close"
と言っています。私は間違って何をしていますか?
ポストlogcatエラーメッセージを使用します。 – kosa