List Item Selected Behavior
When I change the background color of a list item it no l开发者_开发问答onger flashes green when selected. Is there a way to retain this default behavior when the background is changed?
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.
u can set the background resource for the view with
setBackgroundResource(android.R.drawable.menuitem_background);
and get the desired effect
精彩评论