Tom
Tom

Reputation: 461

List Item Selected Behavior

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

Answers (2)

CommonsWare
CommonsWare

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

the100rabh
the100rabh

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

Related Questions