0

I have a button that plays a sound clip when it is pressed. I would like the button to appear pressed during the duration of the sound clip. By that, I mean that I would like the button to take on the default pressed-button appearance while the sound is playing. How can I implement this? I have tried using a number of things in the onClickListener (such as setSelected, requestFocus, etc), but none of those do the trick. I have also tried changing the onClickListener to an onTouchListener, again with no dice. Am I wrong in assuming that there must be a way to simply set the button image to appear pressed? (BTW, the button object is of type Button, not ImageButton).

Thanks for any advice!

Jeremy G
  • 568
  • 4
  • 18

2 Answers2

1

Please see this question. It details a couple of different ways this can be done.

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75
0

Lookup 'selector' drawables and let android take care of this for you.

mastDrinkNimbuPani
  • 1,249
  • 11
  • 14