0

I am trying to make a dice app when a button is clicked a "rolling" image displays for a set amount of time and then switches to dice result. My code just skips the rolling image and waits for the sleep time on whatever the previous result was and then immediately changes to the new result. Any idea what's wrong?

    public void on click(View arg0)
    {
    image.setImageResource(R.drawable.dice_rolling);

    try{
         Thread.sleep(1500);
    }  catch (InterruptedException e) {
         e.printStackTrace();
    }

    image.setImageResource(R.drawable.dice_result);
mattn22
  • 11
  • 1
    you are using `Thread.sleep(1500);` it sleeps for 1.5secs – Sagar Pilkhwal Sep 19 '14 at 06:33
  • If you use Thread.Sleep(), then the thread that you want to do things (ie display rolling image) is suspended (put to sleep) for the period of time. You want to use a `Timer` to make something else happen in 1.5 seconds. – simo.3792 Sep 19 '14 at 06:39
  • Take a look at this [link for animation of dice roll in android](http://www.jasoncavett.com/2011/05/changing-images-during-an-android-animation/) – Sagar Pilkhwal Sep 19 '14 at 06:40

0 Answers0