android - Muliple AlertDialogs on click -


now on click event notice there chance multiple dialogs comes out @ same time on debugger when lags onclick.

how fix it, there way make show 1 alertdialog?

code: pretty standard.

alertdialog.builder builder = new alertdialog.builder(this); builder.setmessage("go next screen?")        .setcancelable(false)        .setpositivebutton("yes", new dialoginterface.onclicklistener() {            public void onclick(dialoginterface dialog, int id) {                 intent = new intent(class1.this, class2.class); startactivity(i);            }        })        .setnegativebutton("no", new dialoginterface.onclicklistener() {            public void onclick(dialoginterface dialog, int id) {                 dialog.cancel();            }        }); alertdialog alert = builder.create() 

using isshowing() method can check alert dialog showing or not ..

and onclick event create new dialog every time when click check if dialog not null create dialog if not null check .isshowing()

so,

alertdialog alert=null;//declare global ..mind not in onclick method  if(null=alert){  alert = new alertdialog.builder(this).create(); }  if(!alert.isshowing()){    //do stuff here dialog showing here...  }  

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -