![](/img/trans.png)
[英]Listview with Checkbox,Textview and button not working correctly in android?
[英]android listview contains checkbox setonItemclick not working
當我點擊listview
包含項目textview
和復選框, setOnItemClickListener
不工作
這是我的java代碼
android listview
包含復選框setonItemclick
不起作用
etiket_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
final Database dbD = new Database(context); // Db bağlantısı oluşturuyoruz. İlk seferde database oluşturulur.
Tags = dbD.Etiketler();
final int temp_id = Integer.valueOf(Tags.get(db.Etiketler().size()-position-1).get("tag_id"));
final int pozisyon=db.Etiketler().size()-position-1;
if (syac % 2 == 0) {
val_tag=val_tag+Tags.get(pozisyon).get("tag")+" ";
tag.setText(val_tag);
syac++;
} else {
String newTags = tag.getText().toString().replaceAll(Tags.get(pozisyon).get("tag"),"");
syac++;
tag.setText(newTags);
}
}
});
這是我的列表項 XML 代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:descendantFocusability="blocksDescendants"
android:weightSum="1">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.09"
android:background="#f8f8f8"
android:descendantFocusability="blocksDescendants"
android:id="@+id/item_li_frame">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="list_item_etiket2"
android:id="@+id/list_item_etiket2"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="6dp"
android:textColor="#4a4a4a"
android:textStyle="bold"
android:focusableInTouchMode="false"
android:focusable="false"
android:textSize="16dp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etiket_checkBox"
android:layout_gravity="right|center_vertical"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_marginRight="16dp" />
</FrameLayout>
</LinearLayout>
Android listview
包含復選框setonItemclick
不起作用
你已經把一個TextView
和CheckBox
在FrameLayout
所以checkBox
處於上述textView
和消耗的觸摸事件。 將它們放在不同的布局中,例如LinearLayout
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.