In an Android application with two ListViews, the goal is to keep the selected item in one ListView highlighted while displaying the details of the selected item in the other ListView.
<ListView android:id="@+id/cli_lista" android:choiceMode="singleChoice" android:listSelector="#666666" ...> </ListView> <ListView android:id="@+id/cli_lista_det" ...> </ListView>
To ensure the selected item in cli_lista remains highlighted:
Set the Choice Mode programmatically:
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
Specify the background color for selected items:
android:listSelector="#666666"
or programmatically:
listView.setSelector(getResources().getDrawable(R.drawable.selector_background));
The above is the detailed content of How to Maintain Highlight Persistence for Selected Items in Android ListView?. For more information, please follow other related articles on the PHP Chinese website!