开发者

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 b开发者_StackOverflowutton 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.).


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
    }
};


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜