AsyncTask에 문제가 있습니다. 3 개의 CheckBox가있는 Activity가 있는데,이 옵션을 선택하면 사용자가 버튼을 누를 때 비동기 작업을 시작합니다. 내 비동기이AsyncTask에서 ProgressDialog가 해제되지 않았습니다.
private class MyTask extends AsyncTask<Void, Void, Void> {
String valore
public MyTask(String valore) {
this.valore = valore;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage(getString(R.string.message));
progressDialog.setIndeterminate(true);
progressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
// Exec some operations
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if(risultato != null) {
textView.append(risultato);
}
if(errori != null) {
textView.append(errori);
}
progressDialog.dismiss();
}
}
그리고
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(checkBox.isChecked()) {
new MyTask("string").execute();
}
if(checkBox2.isChecked()) {
new MyTask("string2").execute();
}
if(checkBox3.isChecked()) {
new MyTask("string3").execute();
}
}
});
문제는 두 개 또는 세 개의 확인란이 선택하는 경우해서 ProgressDialog 기각하고 화면에 남아 있지 않은지있는 버튼입니다. 왜? 두 개 이상의 체크 박스가 선택되어있을 때 어떻게 취소 할 수 있습니까?