-1
나는 새로운 안드로이드 개발자로서이 AsyncTask를 작동, 나는 이런 식으로 대화 진행에 기본 광고를 필요로 할해서 ProgressDialog 내가 구현하는 지침. 어떻게 가능합니까? 도와주세요.AsyncTask를 사용자 정의는
내 코드 :
private class AsyncTaskRunner extends AsyncTask<String, String, String> {
private String resp;
ProgressDialog progressDialog;
View customProgress;
@Override
protected String doInBackground(String... params) {
publishProgress("Sleeping..."); // Calls onProgressUpdate()
try {
int time = Integer.parseInt(params[0]) * 1000;
Thread.sleep(time);
resp = "Slept for " + params[0] + " seconds";
}
catch (InterruptedException e) {
e.printStackTrace();
resp = e.getMessage();
}
catch (Exception e) {
e.printStackTrace();
resp = e.getMessage();
}
return resp;
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPostExecute(java.lang.Object)
*/
@Override
protected void onPostExecute(String result) {
// execution of result of Long time consuming operation
finalResult.setText(result);
progressDialog.dismiss();
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPreExecute()
*/
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.ic_launcher));
progressDialog.setCancelable(false);
progressDialog.setMessage("Downloading! Please wait...!" + time.getText().toString() + " seconds");
progressDialog.show();
}
}