Selector for custom list view “Change ListView background - strange behaviour”

◇◆丶佛笑我妖孽 提交于 2019-12-01 14:27:44
Javanator

Check the following link. here i mentioned a complete code to use listview properly. Using this we can achieve any listview behavior. We can embed animation also.

Change ListView background - strange behaviour

Hope this help :)

Just change a word here from listSelector to background. Because you want it as the background drawable selector, right?

        <ListView
          android:id="@+id/select_names_tags_lv"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
                android:background="@drawable/list_selector"
          android:layout_alignParentTop="false"
          android:layout_gravity="center_vertical">
        </ListView>

EDIT:

try changing your selector file to (I changed the order of the two items):

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
        android:drawable="@drawable/list_selector_background_pressed" />
    <item android:state_focused="true"
        android:drawable="@drawable/list_selector_background_focus" />
</selector>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!