Problem with ImageButton.setVisibility()
Posted
by Luis Lopez
on Stack Overflow
See other posts from Stack Overflow
or by Luis Lopez
Published on 2010-04-24T01:04:33Z
Indexed on
2010/04/24
1:13 UTC
Read the original article
Hit count: 418
Hello guys!
I'm having a problem when setting the visibility of two image buttons one on top of the other. The idea is to implement a play/pause control. The problem is that the only part where setting the visibility actually works is in the click listeners of the buttons. If I try to change it somewhere else nothing happens. Any idea why is this happening?
Thanks in advance!
playBtn.setOnClickListener(new OnClickListener() {//PLAY BUTTON LISTENER public void onClick(View v) { playBtn.setVisibility(ImageButton.GONE); pauseBtn.setVisibility(ImageButton.VISIBLE); mp.start(); }});
pauseBtn.setOnClickListener(new OnClickListener() {//PAUSE BUTTON LISTENER public void onClick(View v) { pauseBtn.setVisibility(ImageButton.GONE); playBtn.setVisibility(ImageButton.VISIBLE); mp.pause(); }});
final class SeekBarTask extends TimerTask { public SeekBarTask(int duration) {
} @Override public void run() { if(seekBar.getProgress() >= mp.getDuration()) {//IF SONG HAS FINISHED... pauseBtn.setVisibility(ImageButton.GONE);//THESE ONES playBtn.setVisibility(ImageButton.VISIBLE);//DOESN'T WORK mp.stop(); } else { seekBar.incrementProgressBy(100); } } }
© Stack Overflow or respective owner