0

Possible Duplicate:
Android ImageButton with a selected state?

I was wondering whether there is a way to change the image of an ImageButton when it is clicked on? It is supposed to be a play/pause button so if the audio is playing then the image should be "pause" and once the user clicks pause the image should show "play" thanks in advance

Community
  • 1
  • 1
user1291437
  • 81
  • 1
  • 2
  • 11
  • This is pretty much a duplicate of http://stackoverflow.com/q/2604599/190711 or http://stackoverflow.com/q/2716686/190711. Hope that helps. – Mikael Ohlson Jun 17 '12 at 13:16
  • You may refer this question. [http://stackoverflow.com/questions/2617969/how-can-i-change-the-images-on-an-imagebutton-in-android-when-using-a-ontouchlis][1] This has what you want. [1]: http://stackoverflow.com/questions/2617969/how-can-i-change-the-images-on-an-imagebutton-in-android-when-using-a-ontouchlis – harsh Jun 17 '12 at 13:16

3 Answers3

0

u can create method for pressed and also method for release. in pressed method give image of oause, and in release method just give the image of play

Sajid
  • 320
  • 3
  • 20
0

this sounds more of a toggleButton rather than a simple imageButton , since it has 2 states : playing , and paused/stopped .

android developer
  • 114,585
  • 152
  • 739
  • 1,270
0

You have two options in this case :

Either Use TOGGLE BUTTON

or

Handle Clickable Event of your ImagButton i.e on its click change the Image Dynamically.Even you can have two buttons when

  1. When Play button is pressed : Set Visibility of pause button true and for play Button Set visibility gone

  2. When Pause button is pressed : Set Visibility of play button true and for pause Button Set visibility gone

Harneet Kaur
  • 4,487
  • 1
  • 16
  • 16