Add Spinning Wheel Progress Bar In Android -


i try add spinning wheel progress bar in module in android.but not working.

by click on send button want add spinning wheel.tell me add , how add.

my code is:

fragment send job.java

public class fragmentsendjob extends fragment implements onclicklistener {     // fragment called mainactivity      textview newmember,forgot,view;      edittext uedit,pedit;      vibrator vibe;     string euid,epass;      string name,pass;     string status_key;      private static mydialog dialog1;      bitmap bitmap1, bitmap2,bitmap3;     bitmap[] bitmap;     string[] driver_details;     private byte imageinbyte1[],imageinbyte2[],imageinbyte3[] ;     private context mcontext;     private string mname,mobile,desc;      public string advertisement_count;     private button submit,cancel;     private edittext ename,mobno,picktime,unit,street,suburb,destination,fare,city;     private spinner state,group;     private viewgroup vgroup ;  // name of para meter on send job module     private string sename,smobno,spicktime,sunit,sstreet,ssuburb,sstate, ssendjob,scity,sdestination,sfare,sgroup,login_token;      private static fragmentdialog dialog;     private  sendjobdatabase db;      static final int dialog_id = 0;     private typeface ftype;      private sharedpreferences pref1,pref;     string latitude,longitude;     public string job_id;        public fragmentsendjob(){}       @override      public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate)        {         view rootview = inflater.inflate(r.layout.sendjob_fragment, container, false);         pref1=this.getactivity().getsharedpreferences("locdetails", getactivity().mode_world_readable);         pref=this.getactivity().getsharedpreferences("driver", getactivity().mode_world_readable);         login_token=pref.getstring("login_token","login_token");          latitude = pref1.getstring("latitude","latitude");          longitude = pref1.getstring("longitude","longitude");           ename = (edittext) rootview.findviewbyid(r.id.ename);         mobno  = (edittext) rootview.findviewbyid(r.id.mobno);         picktime  = (edittext) rootview.findviewbyid(r.id.picktime);         unit  = (edittext) rootview.findviewbyid(r.id.unit);         street  = (edittext) rootview.findviewbyid(r.id.street);         suburb  = (edittext) rootview.findviewbyid(r.id.suburb);         destination  = (edittext) rootview.findviewbyid(r.id.destination);         state = (spinner) rootview.findviewbyid(r.id.state);         fare=(edittext)  rootview.findviewbyid(r.id.fare);         group = (spinner) rootview.findviewbyid(r.id.group);         city  = (edittext) rootview.findviewbyid(r.id.city);         vgroup = (viewgroup) rootview.findviewbyid(r.id.rel);          submit = (button) rootview.findviewbyid(r.id.submit);          submit.setonclicklistener(new onclicklistener() {                  public void onclick(view v) {                     // todo auto-generated method stub                       new sendjob().execute();               /*  intent intent =new intent(getactivity(),getcurrentlocation.class);                 startactivity(intent);                   system.out.println(">>>>>>>>>>>>>>>>>"+latitude+"***********");                 system.out.println(">>>>>>>>>>>>"+longitude+"***********");*/                   }              });            cancel = (button) rootview.findviewbyid(r.id.cancel);         cancel.setonclicklistener(new onclicklistener() {              public void onclick(view v) {                 // todo auto-generated method stub             (int = 0, count = vgroup.getchildcount(); < count; ++i) {                     view view = vgroup.getchildat(i);                     if (view instanceof edittext) {                         ((edittext)view).settext("");                     }                 }                  }                }); //state spinner represents different state on click         string[] mystate= new string[]{"new south wales","victoria","queensland","northern territory","western australia","south australia"};                arrayadapter<string> adapter = new arrayadapter<string>(this.getactivity(), r.layout.listrow, mystate);          state.setadapter(adapter);                    state.setonitemselectedlistener(new onitemselectedlistener() {                              public void onitemselected(adapterview<?> arg0, view arg1,int pos, long arg3) {                                 // todo auto-generated method stub                                  scity =  state.getselecteditem().tostring();                     string s1=arg0.getitematposition(pos).tostring();                         if(s1.equals("new south wales"))                             city.settext("sydney");                         else if(s1.equals("victoria"))                             city.settext("melbourne");                         else if(s1.equals("queensland"))                             city.settext("brisbane");                         else if(s1.equals("northern territory"))                             city.settext("darwin");                         else if(s1.equals("western australia"))                             city.settext("perth");                         else if(s1.equals("south australia"))                             city.settext("adelaide");                               }                             public void onnothingselected(adapterview<?> arg0) {                                 // todo auto-generated method stub                              }                         });                   string[] mygroups= new string[]{"my group","my secondary group","everyone"};                 arrayadapter<string> adapters = new arrayadapter<string>(this.getactivity(),                         r.layout.listrow, mygroups);                 group.setadapter(adapters);                  group.setonitemselectedlistener(new onitemselectedlistener() {                              public void onitemselected(adapterview<?> arg0, view arg1,                                     int pos, long arg3) {                                 // todo auto-generated method stub                                  ssendjob = group.getitematposition(pos).tostring();                                 //gender.settext(setgender);                             }                              public void onnothingselected(adapterview<?> arg0) {                                 // todo auto-generated method stub                              }                         });         return rootview;        } 

//web services data

    private class sendjob extends asynctask<string, string, string[]> {         progressdialog pdialog = new progressdialog(getactivity());          @override         protected string[] doinbackground(final string... params)          {             connectivitymanager conmgr = (connectivitymanager) getactivity().getsystemservice(context.connectivity_service);             if (conmgr.getactivenetworkinfo() != null                     && conmgr.getactivenetworkinfo().isavailable()                     && conmgr.getactivenetworkinfo().isconnected())              {                 httpclient httpclient = new defaulthttpclient();                 try                  {                  system.out.print("***** login token *****"+login_token);                 jsonobject job= new jsonobject();                 sename = ename.gettext().tostring();                 smobno = mobno.gettext().tostring();                 spicktime = picktime.gettext().tostring();                 sunit = unit.gettext().tostring();                 sstreet = street.gettext().tostring();                 ssuburb = suburb.gettext().tostring();                 sstate = state.getselecteditem().tostring();                 scity = city.gettext().tostring();                 sdestination = destination.gettext().tostring();                 sgroup = group.getselecteditem().tostring();                 sfare = fare.gettext().tostring();                  sename.replace("" ,"%20");                 smobno.replace("" ,"%20");                 spicktime.replace("" ,"%20");                 sunit.replace("" ,"%20");                 sstreet.replace("" ,"%20");                 sstate.replace("" ,"%20");                  ssuburb.replace("" ,"%20");                 scity.replace("" ,"%20");                 sdestination.replace("" ,"%20");                 sgroup.replace("" ,"%20");                 sfare.replace("" ,"%20");                       job.put("name",sename);                      job.put("mobile_no",smobno);                      job.put("pickup_time",spicktime);                      job.put("unit_no",sunit);                      job.put("street_name",sstreet);                      job.put("state",sstate);                      job.put("suburb",ssuburb);                      job.put("city",scity);                      job.put("destination",sdestination);                      job.put("group",sgroup);                      job.put("fare",sfare);                      job.put("latitude",latitude);                      job.put("longitude",longitude);                      job.put("status_key","2");                      job.put("method","send_job");                      job.put("login_token",login_token);                      stringentity se = new stringentity(job.tostring());                     httppost httppost = new httppost("http://suntechwebsolutions.com/clients/mobileapp_now/webservice.php");                     httppost.setentity(se);                     httpresponse response = httpclient.execute(httppost);                     string data = entityutils.tostring(response.getentity());                     log.i("response", data);                      system.out.println("response "+data);                     string call;                     call = data;                                  system.out.println("print me............."+call);                                  jsonobject jo = new jsonobject(data);                                 log.d("response", jo.tostring(4));                                  /*jsonobject jobid= jo.getjsonobject("id");                                   job_id=jobid.getstring("id");*/                                   if(jo.getstring("err-code").equals("0"))                                 {                                      databaseadmin admin = new databaseadmin(getactivity());                                     try                                     {                                     admin.insert_user(smobno, sename, smobno, sdestination, sstate, "0", spicktime, sunit, sstreet, ssuburb, scity, sfare, sgroup);                                     }                                     catch(exception e)                                     {                                         e.printstacktrace();                                     }                                     final alertdialog.builder alert = new alertdialog.builder(getactivity());                                     alert.settitle("alert!!!");                                     alert.setmessage(jo.getstring("message"));                                     alert.setpositivebutton("ok",                                             new dialoginterface.onclicklistener() {                                         public void onclick(dialoginterface dialog,                                                 int whichbutton)                                          {                                             pdialog.dismiss();                                             dialog.dismiss();                              /*   intent intent =new intent(getactivity(),handledata.class);                                     intent.putextra("pickupsuburb", ssuburb);                                     intent.putextra("destination", sdestination);                                     startactivity(intent);*/                                            }                                     });                                     getactivity().runonuithread(new runnable() {                                         public void run() {                                             alert.show();                                         }                                     });                                 }                                 else                                 {                             final alertdialog.builder alert = new alertdialog.builder(getactivity());                                     alert.settitle("alert !");                                     alert.setmessage(jo.getstring("message"));                                     alert.setpositivebutton("ok",                                             new dialoginterface.onclicklistener() {                                         public void onclick(dialoginterface dialog,                                                 int whichbutton) {                                             dialog.dismiss();                                           }                                     });                                     getactivity().runonuithread(new runnable()                                      {                                         public void run()                                          {                                             pdialog.dismiss();                                             alert.show();                                         }                                     });                                 }                              }                             catch (exception e)                              {                                 e.printstacktrace();                             }                         }             else             {                 final alertdialog.builder alert = new alertdialog.builder(getactivity());                 alert.settitle("alert !");                 alert.setmessage("no internet connection ");                 alert.setpositivebutton("ok",                         new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog,                             int whichbutton)                      {                         dialog.dismiss();                        }                 });                 getactivity().runonuithread(new runnable()                  {                     public void run()                      {                         pdialog.dismiss();                         alert.show();                     }                 });             }                         return params;                     }                     @override                     protected void onpostexecute(string[] result)                      {                          super.onpostexecute(result);                     }               } public void onclick(view arg0) {         // todo auto-generated method stub      }  public void onlocationchanged(location arg0) {     // todo auto-generated method stub  }  public void onproviderdisabled(string arg0) {     // todo auto-generated method stub  }  public void onproviderenabled(string arg0) {     // todo auto-generated method stub  }  public void onstatuschanged(string arg0, int arg1, bundle arg2) {     // todo auto-generated method stub  } } 

i think forget .show() progress dialog

pdialog.show(); 

and implement pdialog in onpreexecute() in asynctask so,

    @override     protected void onpreexecute() {     super.onpreexecute();     mprogressdialog = new progressdialog(getactivity());     mprogressdialog.setmessage("loading please wait....");     mprogressdialog.setprogressstyle(progressdialog.style_spinner);     mprogressdialog.setcancelable(false);     mprogressdialog.show();     } 

and dismiss progress dialog in onpostexecute(....) so,

               @override                 protected void onpostexecute(string[] result)                  {                     super.onpostexecute(result);                     pdialog.dismiss();                  }        

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 -