RAAAAM
RAAAAM

Reputation: 3380

Android dialog box

Is it possible to give a time limit in dialog box like a toast message. I want to display a set of strings in toast or dialog message box with button option. I used custom toast box previously, but i cant able to insert a button over the toast message. some of my friends suggested to implement dialog box instead of using Toast message. is there any possible to give Time limit in dialog box,(like Toast.long or shot.).

Upvotes: 0

Views: 965

Answers (3)

Farhan
Farhan

Reputation: 13390

TimerTask would not be a good choice since you can not change the UI thread from TimerTask; Use Handler instead.... You can do this by using handler and runnable... simply use handler to call the runnable after some time. and in runnable simply dismiss the dialoge....

Handler h = new Handler();

h.postDelayed(runnable, delayMillis);

where runnable can be define as:

public Runnable r = new Runnable()
{       
    public void run() 
    {
    // TODO Auto-generated method stub
    }
};

Upvotes: 1

Ashish
Ashish

Reputation: 1567

when you call show() method after that you can start a counter after a certain interval when the counter condition is true then you can set the visibility of dialog box is false by calling dismiss() method.

Upvotes: 0

pankajagarwal
pankajagarwal

Reputation: 13582

create a dialog, then create a TimerTask and in the run method dismiss/cancel the dialog. Then create a Timer and schedule this task to be run after our desired time

Upvotes: 0

Related Questions