I have an alert box, created through the following code:
private AlertDialog makeAndShowDialogBox(){
myDialogBox =
new AlertDialog.Builder(this)
//set message, title, and icon
.setTitle("Terminator")
.setMessage("Are you sure that you want to quit?")
.setIcon(android.R.drawable.btn_star)
//set three option buttons
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//whatever should be done when answering "YES" goes here
functionShow(myDialogBox);
}
})//setPositiveButton
/* .setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//whatever should be done when answering "NO" goes here
msg = "Cancel " + Integer.toString(whichButton);
txtMsg.setText(msg);
}
})*/
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//whatever should be done when answering "NO" goes here
msg = "NO " + Integer.toString(whichButton);
txtMsg.setText(msg);
}
})//setNegativeButton
.create();
return myDialogBox;
}
The alert box vanishes as soon as the user selects OK. But i want the alert box to still wait for a particular time before vanishing as i want to change the message on the alert box. How can i do it?
functionShow has following definition:
void functionShow(final AlertDialog dia)
{
dia.setMessage("Generating Unique ID ... Please Wait ");
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
dia.setMessage("Notyfying the user ... Please Wait");
}
}, 10000);
Handler handler1 = new Handler();
handler1.postDelayed(new Runnable () {
public void run()
{
dia.setMessage("Your unique id is 0001. Kindly wait for the other person to respond");
}
}, 15000);
}
But the program checks out as soon as i click ok ... without showing other messages.