In my application, I want to have a different background to the item which is selected in the ListView
. In fact I don't have a plain ListView, its ListFragment
out of which I am getting my ListView through getListView()
method. I applied the selector programmatically like:
ListView listview = getListView();
listview.setSelector(R.drawable.tablet_settings_list_selector);
And the list selector xml is like,
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:state_focused="false"
android:drawable="@drawable/tablet_menu_panel" />
<item android:state_pressed="true" android:state_focused="true"
android:drawable="@drawable/tablet_menu_panel_ontap" />
<item android:state_activated="true"
android:drawable="@drawable/tablet_selected_menu" />
</selector>
This is how my list should look like:
As you can see, the selected list item has different background with an outward arrow to it. So how can I achieve this?