I have ListView inside music player (not ListActivity) and I tried I think everything on stackoverflow and after click on item, row is still not in another color. This is my code for ListView:
<ListView
android:id="@+id/myMusicList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#242424"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selectorr"
android:paddingRight="20dp"
android:choiceMode="singleChoice"/>
This is my list selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:state_pressed="false"
android:drawable="@android:color/holo_red_light" />
<item
android:state_pressed="true"
android:drawable="@android:color/holo_blue_light" />
<item
android:state_selected="true"
android:state_pressed="false"
android:state_focused="false"
android:drawable="@android:color/holo_orange_light" />
</selector>
and the row:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="5dp"
android:focusable="false">
<TextView
android:id="@+id/songTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:padding="10dp"
android:color="#f3f3f3"
android:focusable="false"/>
</LinearLayout>
And this is the code:
ListView musicListView = (ListView) findViewById(R.id.myMusicList);
musicListView.setSelection(1);
musicListView.setItemsCanFocus(true);
....
ListAdapter adapter = new SimpleAdapter(this, songsListData, R.layout.playlist_item, new String[] { "songTitle" }, new int[] { R.id.songTitle });
musicListView.setAdapter(adapter);
musicListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
playSong(position);
view.setSelected(true);
}
});
I have no idea what's wrong - I tried "singleChoice", changed selector in another colors, edited focusable and many more...
What could be the problem?