因此,我的AsyncTask
如下所示:
private class AsyncRetriever extends AsyncTask<IotdHandler,Void,IotdHandler>{
ProgressDialog pDialog;
@Override
protected void onPreExecute(){
pDialog = new ProgressDialog(getApplicationContext());
pDialog.setMessage(getResources().getString(R.string.toast_msg1));
pDialog.show();
}
//------------------------------------------------------------------------------
这是
MainActivity
的内部类。但是,LogCat将pDialog.show()
标记为错误。它说,
Unable to start activity ComponentInfo.
我该如何解决?
最佳答案
ProgressDialog需要一个活动上下文。尝试这个:
pDialog = new ProgressDialog(YourActivity.this);