I’m trying to have a ListView that will display each row in a given color, depending on the content of that row, but still allow the selector to draw. As it is now, if I call View.setBackgroundColor on a row, it colors the background properly, but the selector isn’t drawn.
Share
You have three major options.
One approach is to use
android:drawSelectorOnTop="true"and set the selector of yourListViewto be something that is transparent/translucent, so when it is drawn over top of a row, you can still see the row contents.Or, you will need to set the row backgrounds not to a color, but to a
StateListDrawable, where the background color is set to be transparent when the row is selected, so the regular selector (drawn behind the row) is visible.You are also welcome to register a selection listener with the
ListViewand do custom color changes based on when the selection changes.