android - How do I add an alert dialog on a onClick method? -


i want add alert dialog have loading state while request executed. possible like:

xbutton.setonclicklistener(new view.onclicklistener() {     @override     public void onclick(view v) {         xbutton.setvisibility(view.invisible);          alertdialog alertdialog = new alertdialog.builder(this).create();          alertdialog.setmessage(please wait);         alertdialog.show();          // work here         alertdialog.dismiss      } });          }         return view;      

thank in advance

if don't have specific reason use alert dialog can use progress dialog.

@override public void onclick(view v) {     xbutton.setvisibility(view.invisible);              new asynctask<void, void, void>(){                      progressdialog mprogressdialog;                     @override                     protected void onpreexecute() {                         super.onpreexecute();                         mprogressdialog = new progressdialog(<youractivityclassname>.this);                         mprogressdialog.setmessage("message");                         mprogressdialog.setprogressstyle(progressdialog.style_spinner);                         mprogressdialog.setcancelable(false);                         mprogressdialog.show();                     }                      @override                     protected void doinbackground(void... params) {                         // work                         return null;                     }                      protected void onpostexecute(void result) {                         super.onpostexecute(result);                         mprogressdialog.dismiss();                     };                  }.execute();   } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -