android - progress Dialog simpel -


i want add progress dialog button when click on button before new activity apperar, think don't need thread, did search find need thread , many other think s not clear want when clik on progress dialog user wait few sec other activity appear that's all:

btn_newsfeed.setonclicklistener(new view.onclicklistener() {           public void onclick(view view) {             // launching news feed screen             intent = new intent(getapplicationcontext(), customizedlistview.class);             startactivity(i);         }     }); 

there 3 different different ways in can use progressdailog -using threads, handlers , async tasks. here example of async task using progress dialog

    private class operation extends asynctask<string, void, string> {            @override           protected string doinbackground(string... params)  { // code executed in background thread                  for(int i=0;i<5;i++) {                     try {                         thread.sleep(1000);                     } catch (interruptedexception e) {                         // todo auto-generated catch block                         e.printstacktrace();                     }                 }                  return "executed";           }                  @override           protected void onpostexecute(string result) { // runs on ui thread , updated ui after executing doinbackground                 progressdialog.dismiss();           }            @override           protected void onpreexecute() { progressdialog progressdialog = progressdialog.show(mainactivity.this, "title ", "loading...");               progressdialog.show();            }            @override           protected void onprogressupdate(void... values) { // runs on ui thread , starts first            }     }    

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 -