テキストビューと右側にチェックボックスがあるリストビューがあるアクティビティがあります。リストビューの項目をクリックしたときにチェックボックスをチェックしたい。(チェックボックスにはありません)。Androidがメッセージを1つずつチェックして削除するために使用するもののように。
誰でもこれを解決するのを手伝ってもらえますか? 私はオフにしました
android:focusable="false
と
android:focusableInTouchMode="false"
チェックボックスに。
以下は私のリストビューアイテムxmlです。
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="1."
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/textView2"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginRight="22dp"
android:layout_marginTop="-15dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
そして、これは私のコードです:
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// TODO Auto-generated method stub
if(checkbox.isChecked())
checkbox.setChecked(false);
else
checkbox.setChecked(true);
}
});