I have a dialog appear when i press a button with dynamic data but when i press the same button again the same data appears .I used log to find out why the next question is not shows there was a warning that ” Window already focused ignoring focus” Below is the code
protected Dialog onCreateDialog(int id)
{ AlertDialog.Builder dilog = new AlertDialog.Builder(this);
switch (id)
{
case 99:
String qa = showNext(); //gets question from database new question every time
dilog.setTitle("Team A player" + contactList.get(1).getName());
dilog.setMessage(qa);
dilog.setNegativeButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
break;
}
return dilog.create();
}
You create your Dialog and set its data inside onCreateDialog().
The system calls this if it does not have an object for the supplied dialog id.
Once created, this never gets called again. You have to modify the existing dialog with the newest data inside Activity.onPrepareDialog(). That warning is not important, you can ignore it.