android how to put progressdialog in TabActivity

老子叫甜甜 提交于 2019-12-24 23:49: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


回答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:

  1. call dialog.show() method inside the doInBackground() method.
  2. call dialog.dismiss() method inside the onPostExecute() method.


来源:https://stackoverflow.com/questions/6314754/android-how-to-put-progressdialog-in-tabactivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!