I have a Image button which doubles as a play and stop button. I need the image in the button to change when the user click on it the first time, so that it now looks like a stop button. But this won't happen till the thread completes playing the song.
ImageButton Sound;
public void onClick(View v) {
selectRandomSong();
Sound.setBackgroundResource(R.drawable.stop);
v.invalidate();
if(playing)
stop();
else
play();
Sound.setBackgroundResource(R.drawable.play);
}
setBackground
wont reflect on the view as the invalidation does not occur. Where and how should I invalidate this?