如何在数据加载到应用程序时显示图像 15 秒?
How to show image 15 seconds, while data loading to the app?
我正在制作一个应用程序,我正在使用 sqlite 数据库。在我的应用程序首次启动及其 onUpdate 时,我将数据从 xml 文件添加到 sqlite 数据库。因此,在我的应用程序首次启动时,它会显示大约 15 秒的白屏。我想显示我的全屏),~15 秒。我该怎么做?
您可以使用 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);
}
}
我正在制作一个应用程序,我正在使用 sqlite 数据库。在我的应用程序首次启动及其 onUpdate 时,我将数据从 xml 文件添加到 sqlite 数据库。因此,在我的应用程序首次启动时,它会显示大约 15 秒的白屏。我想显示我的全屏),~15 秒。我该怎么做?
您可以使用 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);
}
}