In my android application an activity takes more than 10 seconds to load (it contains a number of TextViews with lengthy text values), now I want to show a progress bar dialog window during the Activity loading? Is it possible by using 'AsyncTask'? if possible then how can I pause the UI thread until AsyncTask to complete,.When I tries to show a dialog before setContentView() call I got an error like android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
Asked
Active
Viewed 1,139 times
4
-
wow, how many textviews do you have in your layout to make it load 10 seconds!? – fklappan Jul 19 '12 at 12:01
-
trying to show a dialog before setContentView() will give you this sort of error only.Show after it and dismiss after setting textview – AkashG Jul 19 '12 at 12:03
-
actually it is a 'report' page thats why I need all textviews in a single activity – user1537684 Jul 19 '12 at 12:04
-
This link will helps you. – Venkatesh Jul 19 '12 at 12:04
-
The above link might be helps you better if no then i will helps further. – Venkatesh Jul 19 '12 at 12:07
1 Answers
1
You can use AsyncTask
and Viewswitcher
to switch between two layouts(each layout is a view).First set your contentView
and in onPostExecute
(after loading) switch your layouts.
Edit:
For more details,see this page.

hasanghaforian
- 13,858
- 11
- 76
- 167