如何将应用程序预加载程序/启动屏幕/启动屏幕添加到我的PhoneGap Android应用程序
我已经使用phone Gap创建了一个Android应用程序。它运行良好。我如何将预加载图像添加到我的应用程序。现在,它在加载应用程序时显示一个白色页面 非常感谢您的帮助, 感谢如何将应用程序预加载程序/启动屏幕/启动屏幕添加到我的PhoneGap Android应用程序,android,cordova,Android,Cordova,我已经使用phone Gap创建了一个Android应用程序。它运行良好。我如何将预加载图像添加到我的应用程序。现在,它在加载应用程序时显示一个白色页面 非常感谢您的帮助, 感谢 VKS.如果您的意思是预加载程序图像具有启动屏幕,请参阅以下代码 对于PhoneGap: public class MyDefaultActivity extends Activity { public void onCreate(Bundle savedInstanceState) { sup
VKS.如果您的意思是预加载程序图像具有启动屏幕,请参阅以下代码 对于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
}
}
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();
}
}
对于Android原生应用程序:
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
}
}
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)的形式存在。您可以创建一个AsyncTask
实现,用于在后台线程中加载应用程序数据时显示图像/进度指示器
onPreExecute
方法显示所选的预加载程序
(图像/进度对话框/等)doInBackground
方法中
开始加载必要的数据,
及onPostExecute
方法中
删除/隐藏预加载程序,以便
活动所需的布局将是
显示如果预加载图像是指大图像的低分辨率版本,则可以使用包含两个图像视图的图像视图:一个图像视图包含预加载图像,而另一个包含完整图像(加载时)。最初,您会使预加载的图像可见,但当大位图加载完毕后,您只需使用
switcher.showNext()
来显示完整图像
一些关于ViewSwitcher的进一步阅读(示例做了类似的事情):hi@Vinayak.B我想问一下我是否有android webview应用程序的代码,但在webview完全加载之前,我想先显示我的公司徽标图像。。我在这里写了一个问题:我真的需要你的建议,谢谢:)