4

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

1 Answers1

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