开发者

Android ListView when Items are Focusable,disables clicks

I am using a ListView with custom adapter it simply has one TextView

<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"

 />

Heres my selector background:

<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"开发者_Python百科 />
<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>

The problem is when I am setting TextView properties: android:clickable="true" and android:focusable="true"

It is then I see my focused version of background, but setting these causes list items to no more respond to clicks and long clicks. When these 2 properties are removed all ListItems respond to clicks and long clicks.

What should be done which would make focusable background visible and click responds both to work.

I have tried calling getListView().setItemsCanFocus(true) but problems still persists.


along with android:focusable, use this on TextView

android:duplicateParentState="true"

Make sue your list items are focusable and clickable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜