0

I have two elements in my activity layout that are set with VISIBILITY=GONE, that I want to make appear one after the other, with a delay of 500 milliseconds. Each time one of them appears i also want to play a sound, however, using a runnable thread on the UI results in sounds playing with the right delay, and both the screen elements appearing at the same time. What is the correct way to do this?

user3603321
  • 39
  • 1
  • 5
  • use an Handler and its postDelayed call – Blackbelt May 19 '14 at 10:33
  • 1
    I think that animation is the solution to your problem, as simple as a fade in animation with delays and a couple of listeners in it you will be good to go, check this out http://stackoverflow.com/questions/3298330/android-alpha-animation-fadein-fadeout-with-delays – Necronet May 19 '14 at 10:34

1 Answers1

3

Use this code:

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
     public void run() {
         //write the code here which you want to run after 500 milliseconds
     }
}, 500);
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Pawan asati
  • 292
  • 2
  • 13