Shruti
Shruti

Reputation: 285

How to put delay between 2 tasks in android?

I have one image-view & when user clicks it,it will open a dialog box with some results.

But i want to display results after 5 seconds of click.

I want to display blank dialog box until 5 seconds & then i want to display results ? how can i do this ? thank you very much.

Upvotes: 0

Views: 131

Answers (1)

Omar Farhat
Omar Farhat

Reputation: 668

Make sure to check handler, copy this code after on click listener.

Handler handler = new Handler(); 
        handler.postDelayed(new Runnable() { 
             public void run() { 
//whatyouwanttodo      
             } 
        }, 5000); 
    }

Upvotes: 6

Related Questions