android - AsyncTask การทำงานในเบื้องหลัง [ แบบ STYLE_HORIZONTAL มีตัวเลขนับ ]
public class HttpGetRequest extends AsyncTask<String, Integer, String>{
private ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
protected void onPreExecute(){
super.onPreExecute();
progressDialog.setMessage("..Loading..");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(50000);
progressDialog.setCancelable(false);
progressDialog.setProgress(0);
progressDialog.show();
}
protected String doInBackground(String... s) {
for (int i=0; i<=50000; i++){
publishProgress(i);
}
return null;
}
protected void onProgressUpdate(Integer... value){
progressDialog.setProgress(value);
}
protected void onPostExecute(String response){
progressDialog.dismiss();
Log.e("status", "success");
}
}
ป้ายกำกับ:
android,
progress dialog,
STYLE_HORIZONTAL