问题
I hav an application where I have an TabActivity and which have 2tabs(each tab as an activity) First tab(an activity) loads data from internet. So I want there a progressdialog until the 1st tab(an activity) loads data from internet.
ProgressDialog.show(TabHostActivity.this, "Working..", "Downloading Data...",true);
pd.dismiss();
only this much code i have which not give satisfaction please anybody tell me what i write to show a progressdialog until it download the data. (means i hav to use thread). Please give me answer along with code Thank you
回答1:
In tabGroupActivity ,use progressDialog in the folllowing way( If your activity is the sub Activity of any tabhost):
ProgressDialog.show(getParent(), "Working..", "Downloading Data...",true);
try this, and one more thing implement ProgressDialog using threads: see this for help : How to get a progress bar on button click?
Hope this will give you some idea on the topic.
回答2:
You should implement AsyncTask inside the First Tab activity, Asynctask is known as PainLess Threading.
Just go through the above 2 links and then do as follows:
- call dialog.show() method inside the doInBackground() method.
- call dialog.dismiss() method inside the onPostExecute() method.
来源:https://stackoverflow.com/questions/6314754/android-how-to-put-progressdialog-in-tabactivity