Android ListView onItemClick Not Work
ListView item中有Button和RadioButton的时候,它的Item点击事件不起作用,需要设置item的属性。
- set the root layout with:
android:descendantFocusability="blocksDescendants"
- set any focusable or clickable view in this item with:
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
Here is an example: listview_item.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginTop="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:gravity="center_vertical" android:orientation="vertical" android:descendantFocusability="blocksDescendants"> <RadioButton android:id="@+id/script_name_radio_btn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textColor="#000" android:padding="5dp" android:clickable="false" android:focusable="false" android:focusableInTouchMode="false" /> </LinearLayout>