カスタムアダプターでListViewを使用していますが、TextViewが1つだけあります
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_content"
android:background="@drawable/list_item1"
android:layout_width="fill_parent" android:layout_height=""wrap_content"
/>
私のセレクターの背景は次のとおりです。
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="@drawable/draw_list_item1" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/draw_list_item_focused" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/draw_list_item_selected" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/draw_list_item_selected" />
<item android:state_focused="true"
android:drawable="@drawable/draw_list_item_focused" />
<item android:drawable="@drawable/draw_list_item1"/>
</selector>
問題は、TextView
プロパティ
android:clickable="true"
を設定しているときです。android:focusable="true"
その後、フォーカスしたバージョンの背景が表示されますが、これらを設定すると、リスト項目がクリックや長いクリックに反応しなくなります。これら 2 つのプロパティが削除されると、すべての ListItems がクリックとロング クリックに応答します。
フォーカス可能な背景を表示し、クリックが両方とも機能するようにするにはどうすればよいですか。
電話をかけてみgetListView().setItemsCanFocus(true)
ましたが、問題は解決しません。