0

リストビューを作成したいのですが、各行に画像とテキストビューを含むチェックボックスがあり、ほぼ完成しましたが、チェックボックスを配置するとlist_rowを押すことができません。つまり、チェックボックスを配置する前に行をクリックすると、私のスタイルで行ったようにホバーしますが、リスト行をクリックしたときにチェックボックスを配置した後、ホバーせず、onitemclick が機能しません。なぜですか?

これは私の各list_rowのxmlです

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/restaurant_list_item_selector"
    android:orientation="horizontal"
    android:padding="5dip" >

    <!-- ListRow Left sied Thumbnail image -->

    <LinearLayout
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="5dip"
        android:background="@drawable/restaurant_list_item_image_bg"
        android:padding="3dip" >

        <ImageView
            android:id="@+id/restaurant_multi_select_list_item_image"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:src="@drawable/rihanna" />
    </LinearLayout>

    <TextView
        android:id="@+id/restaurant_multi_select_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/thumbnail"
        android:layout_toRightOf="@+id/thumbnail"
        android:textColor="#040404"
        android:textSize="15dip"
        android:textStyle="bold"
        android:typeface="sans" />

    <!-- Rightend check box -->

    <CheckBox
        android:id="@+id/restaurant_multi_select_checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true" 
        android:checked="false"
        />

</RelativeLayout>
4

2 に答える 2

2

フォーカス可能な要素 (CheckBox や Button など) を追加すると、リスト項目全体をクリックする機能が無効になり、それらのフォーカス可能性を無効にする必要があります。

xml のチェックボックス属性に以下を追加してから、試してください。

android:focusable="false"
android:focusableInTouchMode="false" 

お役に立てれば!!!

于 2013-01-22T14:58:18.240 に答える
1

ええ、チェックボックスが存在するとビューがクリックできなくなるためです。使用している ImageView と TextView の両方の onClicklistenrs を実装し、リスト行のクリックで必要なのと同じコードをクリックで記述する必要があります。

フォーカスの設定はタッチのみに役立ちますが、チェックボックスのクリックも実装されます

于 2013-01-22T15:06:41.833 に答える