我正在使用Phonegap + Jquery mobile开发一个android应用程序,我在启动应用程序时显示了一个启动画面,但它是一个静态png文件,现在我的客户不断要求在启动画面中提供一些加载指示器,如微调器或进度条当用户等待应用程序加载时。
我按照一个示例在启动屏幕中显示进度条,但它不起作用,下面是我的代码。
主Java:
super.onCreate(savedInstanceState);
final Activity activity = this;
final ProgressBar progessBar1;
View footer = View.inflate(getContext(), R.layout.spinner, null);
root.addView(footer);
progessBar1 = (ProgressBar) findViewById(R.id.progressBar1);
this.appView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 1000);
if(progress < 100 && progessBar1.getVisibility() == ProgressBar.GONE) {
progessBar1.setVisibility(ProgressBar.VISIBLE);
}
progessBar1.setProgress(progress);
if(progress == 100) {
progessBar1.setVisibility(ProgressBar.GONE);
}
Log.d("Progress", progress+"");
}
});
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.setStringProperty("loadingDialog", "Wait, loading packages ...");
super.loadUrl("file:///android_asset/www/index.html", 12000);
super.setIntegerProperty("loadUrlTimeoutValue", 12000);
和 res/layout 中的 spinner.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:maxHeight="10dip"
android:minHeight="10dip" />
</LinearLayout>
但它不显示进度条。
我的问题:
任何人都可以帮助指出我做错了什么,谢谢。
任何其他方式来做到这一点,实际上我只想在启动屏幕上显示一个微调器,就可以了。