我在我的自定義對話框中使用AsyncTask。 AsyncTask在活動中正常工作,但內部對話框不顯示ProgressDialog。 嘗試從對話框,顯示對話框,應用上下文的活動中執行privid上下文。 結果相同:沒有ProgressDialog顯示在我的屏幕上。AsyncTask在對話框中不顯示ProgressDialog
private class ClearCache_Task extends AsyncTask<Integer,Integer,Integer>
{
private ProgressDialog progressBar;
private ArrayList<String> m_subfolders;
private final Context m_con;
public ClearCache_Task(Context con, ArrayList<String> subfolders)
{
m_con = con;
m_subfolders = subfolders;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
progressBar = new ProgressDialog(m_con);
progressBar.setIndeterminate(true);
progressBar.setCancelable(false);
progressBar.setMessage("Please wait...");
progressBar.show();
}
@Override
protected void onPostExecute(Integer result)
{
super.onPostExecute(result);
progressBar.dismiss();
}
@Override
protected Integer doInBackground(Integer... params)
{
try
{
m_KFileStorage.ClearCache(m_subfolders);
}
catch (Exception e)
{
e.printStackTrace();
Log.e(AppTag, e.toString());
}
return 0;
}
請發佈您的AsyncTask的代碼。 – kaspermoerch
如果執行onPreExcute,您是否檢查過debuger? –