我可以得到一个进度条显示以下code
I can get a progress bar to appear with the following code
pd = ProgressDialog.show(myActivity.this, "", "Loading. Please wait...", true);
直线前进,但一旦我有code执行我希望它去了,但是当我运行解雇方法后,我从来没有看到该对话框中显示的。
straight forward, but once I have the code execute I want it to go away, but when I run the dismiss method after I never see the dialog box show at all.
继承人的code在上下文中被包裹在OnCreate中
Heres the code in context which is wrapped in oncreate
pd = ProgressDialog.show(myActivity.this, "", "Loading. Please wait...", true);
runCode();
setListAdapter(new CustomAdapter(myActivity.this));
pd.dismiss();
我想你可以显示/驳回活动进度对话框的任何地方,但我一定是错的。
I thought you can show/dismiss progress dialog's anywhere in the activity but I must be wrong.
这里是我开始工作的code
here is the code that I got to work
private class UpdateFeedTask extends AsyncTask<MyActivity, Void, Void> {
private ProgressDialog mDialog;
protected void onPreExecute() {
Log.d(TAG, " pre execute async");
mDialog = ProgressDialog.show(MyActivity.this,"Please wait...", "Retrieving data ...", true);
}
protected void onProgressUpdate(Void... progress) {
Log.d(TAG, " progress async");
}
@Override
protected Void doInBackground(MyActivity... params) {
// TODO Auto-generated method stub
return null;
}
protected void onPostExecute(Void result) {
Log.d(TAG, " post execute async");
mDialog.dismiss();
}
}