I am trying to make this simple app. Any help would be appreciated, thank you. What I want it to do. 1: Show a clickable image ( imageButton) 2:When clicked change imageButton to second image. 3:Then play a sound. 4:Wait a few seconds ( I have been using thread sleep() ) 5:Change image back to the original picture.
Sounds simple right? Well what I am getting is this. 1: Show a clickable image ( imageButton) 2:When clicked it plays the sound. 3:Waits a few seconds. 4:Then sets the imageButton to original. ( I know this part happens because I tried 3 pictures. A starting image, photo2 and last photo1 as a test to see if it was even trying to change the imageButton) The first Image change ( step 2) never happens , even though when I step through the app with a debugger it shows it going to that point. Code--------------------------------------------------------------- package my.picture.changer; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; public class PictureChangerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setButtonClickListener(); } public void setButtonClickListener() { final MediaPlayer mp = MediaPlayer.create(this, R.raw.mysound); final ImageButton imageButton1 = (ImageButton) findViewById(R.id.imageButton1); imageButton1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // set button image to photo2 imageButton1.setImageDrawable(getResources().getDrawable( R.drawable.photo2)); mp.start();// play sound sleeper();// wait 5 seconds // tried moving sleep out of method to see if that made a difference (no) // change button image back to photo1 imageButton1.setImageDrawable(getResources().getDrawable( R.drawable.photo1)); } }); } private void sleeper() { // wait 5 seconds try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } return; } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en