Reputation: 461
When I change the background color of a list item it no longer flashes green when selected. Is there a way to retain this default behavior when the background is changed?
Upvotes: 0
Views: 732
Reputation: 1006944
The "green flash" is part of the background. By replacing the background (presumably, with a simple color), you eliminated the flash.
First, consider whether you should be changing the background of a list item. For example, if you are doing all of the list items this way, perhaps the ListView
should have the background color.
If that does not help, you need to make the background be a StateListDrawable
with the appropriate states.
Upvotes: 2
Reputation: 4147
u can set the background resource for the view with
setBackgroundResource(android.R.drawable.menuitem_background);
and get the desired effect
Upvotes: 1