如何在Android应用程序中使用ksoap下载数据时在水平进度条中显示进度?
这里我使用AsyncTask从服务器获取数据。同时,我需要根据传输的数据和要传输的数据显示水平进度条的进展。
private class SyncIncoData extends AsyncTask<String, Void, String> {
ProgressBar pb;
LinearLayout all;
@Override
protected String doInBackground(String... urls) {
try {
incodata=si.GetSoapData();
db=new SqlConnector(con);
datacheckerInco(incodata);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
all=(LinearLayout)findViewById(R.id.linearLayoutall);
all.setEnabled(false);
pb=(ProgressBar)findViewById(R.id.progressBarsync4);
pb.setVisibility(View.VISIBLE);
back=false;
saleto.setClickable(false);
shipto.setClickable(false);
mate.setClickable(false);
inco.setClickable(false);
off.setClickable(false);
tv4.setText("Synchronizing");
//im4.setVisibility(View.INVISIBLE);
}
@Override
protected void onPostExecute(String result) {
all=(LinearLayout)findViewById(R.id.linearLayoutall);
all.setEnabled(true);
pb=(ProgressBar)findViewById(R.id.progressBarsync4);
pb.setVisibility(View.INVISIBLE);
back=true;
saleto.setClickable(true);
shipto.setClickable(true);
mate.setClickable(true);
inco.setClickable(true);
off.setClickable(true);
tv4.setText("Completed");
//im4.setVisibility(View.VISIBLE);
}
}
答案 0 :(得分:0)