我已经使用手机Gap创建了一个Android应用程序.它运行正常.我如何将预加载器图像添加到我的应用程序.现在它在加载应用程序时显示一个白页.
非常感谢帮助,感谢VKS.
如果您的意思是预加载器图像有Splash屏幕,请参阅以下代码;
对于PhoneGap:
public class MyDefaultActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setIntegerProperty("splashscreen", R.drawable.splash); // Displays the splash screen for android super.loadUrl("file:///android_asset/www/index.html",3000); // Second parameter is duration for delay of splash screen } }
对于Android Native应用程序:
public class MySplashScreen extends Activity { private CountDownTimer lTimer; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.splashscreen); // Contains only an LinearLayout with backround as image drawable lTimer = new CountDownTimer(5000, 1000) { public void onFinish() { closeScreen(); } @Override public void onTick(long millisUntilFinished) { // TODO Auto-generated method stub } }.start(); } private void closeScreen() { Intent lIntent = new Intent(); lIntent.setClass(this, MyLauncherActivity.class); startActivity(lIntent); finish(); } }
确保调用的文件splash.png
存在res/drawable-hdpi/splash.png
(RGBA).