Ljdawson
Ljdawson

Reputation: 12229

Android application loading screen

I'm working on an application that lists a stored library using a ListActivity.

My question is, is when I open application it has a visible loading time before the XML view is inflated. During this time only the application name is shown. This is noticeable on quite a few application out there but others seem to have implemented loading screens and what not.

Does anyone have a solution to this or know how to make a good loading screen?

Cheers!

Upvotes: 16

Views: 18863

Answers (2)

ponkin
ponkin

Reputation: 2441

do your job in AsyncTask and use android.widget.ViewSwitcher for UI. You can switch between two views. Show one view when you start your job(some "Loading" View) and switch to "normal" when job is done.

Upvotes: 3

CommonsWare
CommonsWare

Reputation: 1007359

If your activity is taking more than a couple of tenths of a second to start up, you are doing too much work in onCreate(), onStart(), or onResume(). Move that work to a background thread, perhaps using AsyncTask.

Then, if you want to do something while the background thread is crunching away, you can use a ProgressDialog, or call setContentView() multiple times (initially with a splash screen, then later with the full UI once the background work is done), or whatever.

Upvotes: 24

Related Questions