您正在
ProgressDialog使用空上下文创建。以下代码对我有用。
public class AsyncClass extends AsyncTask<Void, String, Void> { private Context context; ProgressDialog dialog; public AsyncClass(Context cxt) { context = cxt; dialog = new ProgressDialog(context); } @Override protected void onPreExecute() { dialog.setTitle("Please wait"); dialog.show(); } @Override protected Void doInBackground(Void... unused) { SystemClock.sleep(2000); return (null); } @Override protected void onPostExecute(Void unused) { dialog.dismiss(); } }


