如何将图像显示15秒,同时将数据加载到应用程序?

Оле*_*дев -1 android image screen seconds android-layout

我正在制作一个应用程序,我正在使用sqlite数据库.在第一次启动我的应用程序和onUpdate时,我将从xml文件向sqlite db添加数据.因此,在我的应用程序的第一次启动时,它显示我白屏约15秒.我想要显示我的全屏幕,约15秒.我怎么能这样做?

pho*_*van 5

您可以使用SplashActivity显示图像,用于Hander.postDelayed()在startActivity到主屏幕之前将此屏幕延迟15秒.

这是一个例子:

public class Splash extends Activity {

    /** Duration of wait **/
    private final int SPLASH_DISPLAY_LENGTH = 15000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.splashscreen);

        /* New Handler to start the Menu-Activity 
         * and close this Splash-Screen after some seconds.*/

        //Load data

        new Handler().postDelayed(new Runnable(){
            @Override
            public void run() {
                /* Create an Intent that will start the Menu-Activity. */
                Intent mainIntent = new Intent(Splash.this,MainActivity.class);
                Splash.this.startActivity(mainIntent);
                Splash.this.finish();
            }
        }, SPLASH_DISPLAY_LENGTH);
    }
}
Run Code Online (Sandbox Code Playgroud)