I have a problem with "setItemChecked", I try select default item, with a background "listSelector". I think that the error is to "listSelector", but I don't know exactly
My listview :
<ListView
android:id="@+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:listSelector = "@drawable/listitem_background"
android:focusable="true"
android:choiceMode="singleChoice"
android:focusableInTouchMode="true"
>
</ListView>
My code select :
this.listView.setItemChecked(1, true);
But not showing background selected.
When I use :
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {....
Works correctly, change color.
How I can fix this problem ?
Update 20/04/2015 10:07
XML selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@color/android:transparent" />
<item android:drawable="@drawable/button_lila" />
</selector>
After instanciate adapter I try select ítem
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
this.listView.setSelection(2); // not work