Andriod List Selector not working



I am writing a program, in which i am using rounded corner listview, and in list i want to implement list item selector and for that i have written few xmls


Not Working : As per my requirement whenever i do tap on any of list item, the item background has to be changed, but nothing happens when i do click on list item, but able to perform logic operations, like: showing toast, calling activity and so on..


Here is the ListView, which i am using



<ListView
android:id="@+id/listMenus"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:divider="#d9ffffff"
android:layout_below="@+id/textView2"
android:background="@drawable/list_border"
android:listSelector="@drawable/list_selector"
android:scrollbars="none"
android:dividerHeight="1dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="match_parent" />


and below is the xml to make it rounded corner, list_border.xml:



<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://ift.tt/nIICcg">
<solid android:color="#268f8471"/>
<stroke android:width="1dip" android:color="#ffffff" />
<corners android:radius="10dp"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>


list_hover.xml:



<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg"
android:shape="rectangle"
>
<solid
android:color="#c9c9ce"
/>
</shape>


list_normal.xml:



<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg"
android:shape="rectangle"
>
<solid
android:color="#ffffff"
/>
</shape>


list_selector.xml:



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://ift.tt/nIICcg" >
<item
android:state_enabled="true"
android:state_pressed="true"
android:drawable="@drawable/list_hover" />
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="@drawable/list_hover" />
<item
android:state_enabled="true"
android:state_selected="true"
android:drawable="@drawable/list_hover" />
<item
android:drawable="@drawable/list_normal" />
</selector>


Note: I want to keep List with rounded corner ...


No comments:

Post a Comment