3

listViewその名前のリスト項目にカスタムレイアウトを使用していますrow.xml

これは私のrow.xmlファイルです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:orientation="vertical"
    android:descendantFocusability="afterDescendants" >

    <TextView
        android:id="@+id/label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:gravity="right"
        android:textSize="40sp" 
        android:focusableInTouchMode="false"
        android:clickable="false"
        android:focusable="false"  />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center"
        android:orientation="horizontal">

       <Button
           android:id="@+id/delete_btn"
           style="?android:attr/buttonStyleSmall"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="right"
           android:layout_marginRight="5dp"
           android:gravity="right|center"
           android:text="delete" />


    </LinearLayout>

</LinearLayout>

上記のレイアウトではonListItemClick()メソッドが機能しませんが、レイアウトから要素を削除するButtonと正しく機能します。

何が問題なのか教えてください

ありがとう

4

1 に答える 1

1

「ラグナンダン」の​​助けを借りて、私は追加します

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

Button、そして私の問題は解決しました

行にフォーカスがあるButtonため、行を選択できません

于 2013-08-11T07:53:07.850 に答える