如何添加应用程序预装载/启动屏幕/飞溅屏幕到我的PhoneGap Android应用程序

前端之家收集整理的这篇文章主要介绍了如何添加应用程序预装载/启动屏幕/飞溅屏幕到我的PhoneGap Android应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经使用手机Gap创建了一个 Android应用程序.它的工作正常.如何在我的应用程序中添加一个预加载器映像.现在它在加载应用程序时显示一个白页.

帮助高度赞赏,
谢谢,
VKS.

解决方法

如果你的意思是预装载图像有Splash屏幕,请参考以下代码;

对于PhoneGap:

  1. public class MyDefaultActivity extends Activity {
  2.  
  3. public void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. super.setIntegerProperty("splashscreen",R.drawable.splash); // Displays the splash screen for android
  6. super.loadUrl("file:///android_asset/www/index.html",3000); // Second parameter is duration for delay of splash screen
  7. }
  8. }

对于Android Native应用程序:

  1. public class MySplashScreen extends Activity {
  2. private CountDownTimer lTimer;
  3.  
  4. public void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. requestWindowFeature(Window.FEATURE_NO_TITLE);
  7. setContentView(R.layout.splashscreen); // Contains only an LinearLayout with backround as image drawable
  8.  
  9. lTimer = new CountDownTimer(5000,1000) {
  10. public void onFinish() {
  11. closeScreen();
  12. }
  13. @Override
  14. public void onTick(long millisUntilFinished) {
  15. // TODO Auto-generated method stub
  16. }
  17. }.start();
  18. }
  19.  
  20. private void closeScreen() {
  21. Intent lIntent = new Intent();
  22. lIntent.setClass(this,MyLauncherActivity.class);
  23. startActivity(lIntent);
  24. finish();
  25. }
  26. }

确保一个名为splash.png的文件作为res / drawable-hdpi / splash.png(RGBA)存在.

猜你在找的Android相关文章