tags:

views:

24

answers:

1

Hey guys & gals-

I have a clickable TextView with a drawable as its background. I'm looking for the right way to implement a down-state drawable so the background changes when the user presses down. I have been able to almost perfectly replicate this behavior by listening for MotionEvents and changing the background when the user is pressing down.. The only thing that doesn't match up with system-wide down state behavior here is that if the user keeps holding down and moves their finger off the button, the state remains down until they release their finger from the screen... whereas in Maps overlays or Buttons or ListViews or anything else the state immediately goes back to off when the finger moves from the object.

I know there must be some proper way to go about doing this... A nudge in the right direction would be great!

Thanks, Nick

+2  A: 

You need to use a Selector for the background. I'm not sure if there is an official example of how to use Selectors, but I found this site that seems to have a pretty good example:

http://www.craiget.com/2009/03/restyling-android-imagebuttons/

That should get you on the right track.

mbaird
Thanks so much! This should do the trick.
Bloudermilk