我想在片段中創建progressdialog,但不斷顯示錯誤是泄露了最初在此處添加的窗口com.android.internal.policy.impl.phonewindow。請幫助這個我的代碼如何在內部類片段中添加進度對話框
private class ListDaftarHargaAsync extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("retrieving...");
progressDialog.setIndeterminate(false);
progressDialog.setCancelable(false);
}
@Override
protected String doInBackground(String... params) {
try {
modelPost.setDataVouchers();
} catch (JSONException e) {
e.printStackTrace();
}
String result = modelPost.resultString;
if (result.length() != 0) {
progressDialog.dismiss();
}
return null;
}
@Override
protected void onPostExecute(String result) {
progressDialog.dismiss();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
fillDaftarHarga();
}
});
}
}
哪裏progressDialog.show()?併發布完整的錯誤。並刪除progressDialog.dismiss();來自doInBackground。 '在那裏onPostExceute –
刪除'progressDialog.dismiss();'在doInBackground – Yugesh
我試過了,但仍然顯示相同的錯誤 – Ashadi