I followed the official Android site's tutorial on creating contextual action menus. Using the code below, when I long press on one of my ListView items, it does become selected, but it does not visually indicate that its been selected. I am using the Holo Light theme, and I expect the background color of every selected item in my ListView to change to a shade of blue.
Is this normal behavior?
I have tried testing listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
and not even a single row will highlight.
Using listView.setSelector(android.R.color.holo_blue_light);
does appear to highlight the row which was last selected, but it does not highlight the other rows which are selected.
Have I done something wrong, or do I need to make the background change manually? If so, how?
I have also tried listView.setSelector(android.R.drawable.list_selector_background);
which is a real selector that contains items for different states. Unfortunately, it still only applies to the most recently selected ListView item.
public class MyActivity extends ListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The list is generated here
ListView listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setMultiChoiceModeListener(new MultiChoiceModeListener() {
// implements empty methods
}
}
}
Thanks!