Then I have a ListView
set as:
<ListView
android:id="@+id/list_menu_nav"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:listSelector="#fff">
</ListView>
The adapter is set as:
navMenu = (ListView) findViewById( R.id.list_menu_nav );
navMenu.setAdapter( new ArrayAdapter<String>( this,
android.R.layout.simple_list_item_1,
menuList ) );
When I touch in an item, it gets a white background (as I set). But, when I performClick to a item as below, it is selected but doesn't get the white background.
navMenu.performItemClick( navMenu.getChildAt( 1 ), 1, navMenu.getAdapter().getItemId( 1 ) );
I know it is selected because everything else works as expected (listener called, getCheckedItemPosition
returns correct value).
What is the correct approach in this case? Substitute the layout for a custom one and make by myself the highlightening or is there a way using the same default layout?
You have just TextView
according to this:
So this behaviour is expected. You have to create own layout for item element to customise selected state. Take a look here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With