jidh
jidh

Reputation: 172

Hide alert dialog in android

I have a simple alert dialog, it ll display when a button click is occurs. and hide automatically after receiving data from web service (On Button click ) .

The code below is showing the alert dialog, but i cant hide it after receiving data also.

alertDialog1.setTitle("Please Wait");
                        alertDialog1.setCancelable(false);
                        alertDialog1.setMessage("Fetching Info");
                        alertDialog1.show();`

Upvotes: 6

Views: 14282

Answers (2)

KoLiBer
KoLiBer

Reputation: 31

alertdialog1.setPositiveButton("Close", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });

Upvotes: 2

codeMagic
codeMagic

Reputation: 44571

After you receive your data (don't know how/where you are getting the data) call dismiss()

alertDialog1.dismiss();

Upvotes: 6

Related Questions