Maybe it is not the best approach, but my application use onCreate
for loading/preparing quite many layouts into ViewAnimator
, so after the application start, I have every screen of my app prepared for use. So changing different screens is smooth and fast.
The drawback of this method is, that it takes 5 seconds for the first layout to appear. To be exact - all screens of ViewAnimator
are defined in XML layout and I supose they are inflated during onCreate
.
My application must have a splashscreen, so my question is, if there is some way to use also these 5 seconds to show some image?
EDIT :
Thanks to your answers I came up with this simple solution:
Activity activity;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_splash);
activity = this;
LinearLayout splash_layout = (LinearLayout) this.findViewById(R.id.splash_layout);
// after 1 second of splash screen, start initializing everything
splash_layout.postDelayed(new Runnable()
{
public void run()
{
activity.setContentView(R.layout.main);
// Here init whole layout and all class
// During initialization, the splashscreen is still visible
}
}, 1000);
}