B.Arunkumar wrote:
> Hi,
>
>    Actually this is not the way that I am handling the alert dialogs
> in my code:
> In the oncreate, I have defined an alert dialog builder as follows:
>
> onCreate():
>
> AlertDialog.Builder alert_box_builder=new
> AlertDialog.Builder(AsyncRecordTrial.this);
>
> In various situations, I generate an alert dialog as follows:
>
> Situation1:
>
> alert_box = alert_box_builder.create();
> alert_box.setIcon(R.drawable.icon);
> alert_box.setMessage(dialogmessage);
> alert_box.setButton("Ok",new DialogInterface.OnClickListener() {
> @Override
> public void onClick(DialogInterface dialog, int which) {
> // TODO Auto-generated method stub
>          dialog.cancel();
> }
> });
>
> alert_box.setOnCancelListener(new OnCancelListener(){
> @Override
> public void onCancel(DialogInterface dialog) {
> // TODO Auto-generated method stub
>      finish();
> }
> });
> alert_box.show();
>
> Similarly for Situation2:
>
> alert_box = alert_box_builder.create();
> ...
> ...
> alert_box.show();
>
> Similarly for Situation3:
>
> alert_box = alert_box_builder.create();
> ...
> ...
> alert_box.show();
>
> and so on...
>
> Now sometimes, 2 or more of these alert dialog boxes gets generated on
> top of each other. alert_box is not a global variable. I am not sure
> how to keep track of the number of boxes that are showing up and how
> to close the other boxes when ok is pressed for one?
>
> Thank you,


use java collections api to keep dialogs that were shown and iterate
over your collection to  hide each dialog

pskink

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