你的位置:首页 > 操作系统

[操作系统]Android ListView onItemClick Not Work


Android ListView onItemClick Not Work

  ListView item中有Button和RadioButton的时候,它的Item点击事件不起作用,需要设置item的属性。

  1. set the root layout with: android:descendantFocusability="blocksDescendants"
  2. 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.

<??><LinearLayout ="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>