1

i have created a android app it works fine and I am loading my UI that contains a scroll tab with several fragments, the UI in the main activity takes 4-6 seconds to load and only a blank white screen is seen till then, how can I show a progressbar till that UI has finished loading there s no data to load just the UI so please dont tell about asynctasks

user2869844
  • 45
  • 1
  • 6
  • 1
    Some apps just place a splash screen image over the main activity. Also, I recommend you go through the optimization guide http://developer.android.com/training/improving-layouts/index.html – elimirks Oct 24 '13 at 10:42
  • @user2869844 r u using any thread for loading data?. – Ram Oct 24 '13 at 10:53
  • If your UI take this long to load, it is not a good sign. You might be better loading the fragments on demand with a [`FragmentPagerAdapter`](http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html) – nicopico Oct 24 '13 at 12:02

2 Answers2

2

You will have to first display a simple activity with your progress bar and then start to add the parts of your ui in background one by one to the activity by using an async task. If you are using commands that can only be performed by the ui thread you have to post them to a view or a handler from your async task. Ensure that the different blocks you are loading are not taking too long to give the ui thread time to update your progress bar in between.

Jan
  • 1,359
  • 1
  • 13
  • 18
1

I know you don't want to use an Async task but that would be the best solution. Start an async task loading the UI (Can use existing class) and read a true false (indicating when done) value from onProgressUpdate(), which can be accessed from the UI thread. Display a spinner while false. Hope this helps.

user1840255
  • 287
  • 1
  • 6
  • 15