Can't try it here, but I think I had some success but calling
'dismiss' ( or was dismissDialog... or rather removeDialog ??? ) on
the dialog in the onClick method.
That way, the dialog will really be closed, and a new one will be
created on the next ShowDialog.

But it's strange that the onPrepareDialog failed for you, because it
is exactly what I'm finally doing, with no trouble.
The only difference is that I also set the text in the OnCreateDialog,
for the first time the dialog is created ( I'm not sure
onPrepareDialog is called the first time ).

Hope it helps,

Emmanuel
http://androidblogger.blogspot.com/

On Jan 6, 1:09 am, "Sarath Kamisetty" <[email protected]>
wrote:
> Hi,
>
> Please see inline ...
>
> On Sun, Jan 4, 2009 at 9:20 PM, RAJENDIRAN SUNDARRAJAN-CPB738
>
> <[email protected]> wrote:
>
> > Hi,
>
> > SetMessage() will effect only when you do OnCreateDialog(). Instead you
> > can try the below options,
> > 1. Have two dialogs with separate Id's ERROR_DIALOG_ID_TEXT1 and
> > ERROR_DIALOG_ID_TEXT2 else
>
> I tried this before, it works but this will end up creating many
> dialogues. If I have manny error conditions, I will end up creating
> and handling as many dialogues.
>
> > 2. Create AlertDialog and use show() function to display it. In this
> > case you will not be requiring showDialog(int) and OnCreateDialog() and
> > OnPrepareDialog().
>
> same here I guess.. except that instead of onCreateDialog() and
> onPrepareDialog() I can have small private function that does the
> job... If I have go with choice 1, I might as well try this one.
>
> Thanks,
> Sarath
>
>
>
> > - sundar
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Sarath
> > Kamisetty
> > Sent: Monday, January 05, 2009 7:50 AM
> > To: [email protected]
> > Subject: [android-developers] Re: AlertDialogs reused ?
>
> > 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to