The problem appears to be that if the message is null when then dialog is first created, it will set the visibility of the TextView that contains the message to GONE, with no way of coming back. (That's why you saw practically nothing.) So when you're using the Builder, set the message to something:
new AlertDialog.Builder(this).setMessage("").create() Then using setMessage in onPrepareDialog works (it did for me, in the eumulator). //Ken On Jan 4, 6:20 pm, "Sarath Kamisetty" <sarath.kamise...@gmail.com> wrote: > Hi, > > Unfortunately moving the code to onPrepareDialog() also didn't help. I > create an instance and setup the button in onCreateDialog() and set > the error string in onPrepareDialog() but that doesn't seem to work. I > see that screen gets a little darker and something very small shows up > (I can't even see the button there). > > protected Dialog onCreateDialog(int id) { > AlertDialog alertDialog; > > switch (id) { > case ERROR_DIALOG_ID: > alertDialog = new AlertDialog.Builder(this).create(); > alertDialog.setButton("OK", new > DialogInterface.OnClickListener() { > public void onClick(DialogInterface dialog, int which) { > return; > } > }); > return alertDialog; > } > return null; > } > > protected void onPrepareDialog(int id, Dialog dialog) { > switch (id) { > case ERROR_DIALOG_ID: > AlertDialog alertDialog = (AlertDialog)dialog; > alertDialog.setMessage(alertString); > //alertDialog.show(); > break; > } > } > > Thanks, > Sarath > > On Sun, Jan 4, 2009 at 5:38 PM, hazmatzak <mc.y...@gmail.com> wrote: > > > Yes, dialogs are reused; that's part of the idea behind having the > > Activity manage the dialogs. Generally, onCreateDialog is called only > > once for a given ID (you can use the debugger to verify this). > > Override onPrepareDialog to modify the created/reused dialog just > > before it appears. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---