当我开始一项新活动时,我的 progressDialog 不会立即出现。我正在使用 AsyncTask 来做同样的事情。我正在下一个活动中从 Web 服务加载数据。以下是我的异步课程:
private class TheTask extends AsyncTask<Void, Void, Void>{
Context con;
Intent aboutusIntent;
TabGroupActivity parentActivity;
private TheTask(Context context)
{
this.con=context;
}
@Override
protected void onPreExecute() {
progDialog = ProgressDialog.show(con, "Loading... ",
"please wait....", true);
}
@Override
protected Void doInBackground(Void... params) {
aboutusIntent = new Intent(con, Departments.class);
parentActivity = (TabGroupActivity)getParent();
//progDialog.show();
return null;
}
@Override
protected void onPostExecute(Void result) {
parentActivity.startChildActivity("Departments", aboutusIntent);
if(progDialog.isShowing())
{
progDialog.dismiss();
}
}
}
我正在创建此类 onClick of button 的实例:
ourdepbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new TheTask(AboutUs.this.getParent()).execute();
}
});
有什么建议么?