I am trying to create custom background selector for my ExpandableListView. It works fine for all states other than focused. I am unable to identify which row is currently focused. Here is the code:
im_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/list_selector_background_focus" />
<item android:state_pressed="true"
android:drawable="@drawable/list_selector_background_pressed" />
<item
android:drawable="@drawable/list_bg" />
</selector>
im_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/im_selector"
android:paddingTop="10px"
android:paddingBottom="10px"
android:paddingLeft="5px"
>
<ImageView android:id="@+id/status_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4px"
/>
<TextView
android:id="@+id/count_text"
android:singleLine="true"
android:layout_width="30px"
android:layout_height="wrap_content"
android:textColor="#fff"
android:layout_alignParentRight="true"
android:background="@drawable/new_msg"
android:padding="2px"
android:layout_marginRight="10px"
android:gravity="center_horizontal"
/>
<TextView
android:id="@+id/list_item_text"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:layout_toRightOf="@id/status_image"
android:layout_toLeftOf="@id/count_text"
/>
</RelativeLayout>
and the listview:
<ExpandableListView android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="horizontal"
android:layout_below="@id/top_bar"
android:layout_marginBottom="45px"
android:divider="#00000000"
android:cacheColorHint="#00000000"
android:listSelector="@layout/im_selector"
android:focusable="true"
/>