android how to put progressdialog in TabActivity

2019-09-12 06:45发布

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

2条回答
戒情不戒烟
2楼-- · 2019-09-12 07:07

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:

  1. call dialog.show() method inside the doInBackground() method.
  2. call dialog.dismiss() method inside the onPostExecute() method.
查看更多
淡お忘
3楼-- · 2019-09-12 07:16

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.

查看更多
登录 后发表回答