android - Loading spinner not showing correctly -


i trying put spinner while data loaded , ui updated task this:

protected void oncreate(bundle savedinstancestate)  {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_road_details);          settitle("details");       startbutt = (button)findviewbyid(r.id.beginjourney);         map = (button)findviewbyid(r.id.map_btn1);      boolean greenbuttstate = getintent().getbooleanextra("greenbuttstate", false);     boolean fastbuttonstate = getintent().getbooleanextra("fastbuttonstate", false);     asynctask<void, void, void> loadingtask = new asynctask<void, void, void>()    {        progressdialog dialog = new progressdialog(roaddetails.this);       @override         protected void onpreexecute()        {           this.dialog.setmessage("message");           this.dialog.show();        }           @override         protected void doinbackground(void... params)         {                 final hashmap<string, object> trip1;              intent intent = getintent();                         mxmlrpcurl = intent.getstringextra("xmlrpcurl");             msessionid = intent.getstringextra("sessionid");             mgetsavedtripfunc = intent.getstringextra("getsavedtripfunc");             newtripid = intent.getintextra("newtripid", 0);             variantid = intent.getintextra("variantid", 0);             week = intent.getintextra("weekstate", 0);             cityname = intent.getstringextra("nameofcity");             flag = intent.getintextra("flag", 0);             startlatitude = intent.getdoubleextra("startlatitude", 0.0);             startlongitude = intent.getdoubleextra("startlongitude", 0.0);             endlatitude = intent.getdoubleextra("endlatitude", 0.0);             endlongitude = intent.getdoubleextra("endlongitude", 0.0);              trip1 = (hashmap<string, object>) intent.getserializableextra("variant");             variant = new variant();             variant.read(trip1);                  startbutt.setonclicklistener(new onclicklistener()              {                  @override                 public void onclick(view v)                  {                     intent intent = new intent(roaddetails.this, localisation.class);                     intent.putextra("sessionid", msessionid);                     intent.putextra("xmlrpcurl", mxmlrpcurl);                     intent.putextra("newtripid", newtripid);                     intent.putextra("variantid", variantid);                     intent.putextra("weekstate", week);                     intent.putextra("nameofcity", cityname);                     intent.putextra("variant", (serializable)trip1);                     intent.putextra("flag", flag);                     intent.putextra("startlatitude", startlatitude);                     intent.putextra("startlongitude", startlongitude);                     intent.putextra("endlatitude", endlatitude);                      intent.putextra("endlongitude",endlongitude);                                                        startactivity(intent);                           }             });              map.setonclicklistener(new onclicklistener()             {                            @override                 public void onclick(view v)                  {                     //intent intent1 = new intent (roaddetails.this, mapdraw.class);                     intent intent1 = new intent (roaddetails.this, osmactivity.class);                     intent1.putextra("sessionid",msessionid);                     intent1.putextra("endlatitude", endlatitude);                      intent1.putextra("endlongitude",endlongitude);                     intent1.putextra("startlatitude", startlatitude);                     intent1.putextra("startlongitude", startlongitude);                     intent1.putextra("variant", (serializable)trip1);                     startactivity(intent1);                 }             });             return null;         }          @override         protected void onpostexecute(void result)          {             gettingdata();             this.dialog.dismiss();                       }     };             loadingtask.execute((void[])null);        } 

however when there delay before opening the activity contains code (i want spinner there while data loaded) spinner not showing. there delay (for data loaded - lets call screen freeze 1 - 3 seconds) , thats it. doing wrong? want spinner show while data loaded , after dismissed. mention in method gettingdata(); changing ui - adding layouts dynamically, adding images etc.

try this...this work

  progressdialog dialog = new progressdialog(roaddetails.this);     this.dialog.setmessage("message");    this.dialog.show();  //start asynchronous task here       load data here  //end asynchronous task   this.dialog.dismiss(); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -