添加加载指示灯/进度条到PhoneGap的Andr​​oid的启动画面指示灯、进度条、加载、画面

2023-09-05 10:44:37 作者:野性の小男人

我有这显示了RES /绘制/ splash.png就好了一个PhoneGap的1.4.1 / 1.0.1 jQueryMobile / Android项目,并启动画面消失,一旦web视图被加载。

I have a PhoneGap 1.4.1 / jQueryMobile 1.0.1 / Android project which is showing the res/drawable/splash.png just fine, and the splashscreen goes away once the WebView is loaded.

我想补充某种进度指示器个文字的启动画面,但没有成功为止。

I would like to add some sort of progress indicator percentage text to the splashscreen but have been unsuccessful so far.

我曾与这样的成功,在过去使用普通的WebView像这样:

I have had success with this in the past by using a normal webview like so:

myWebView.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageFinished(WebView view, String url) {
        myLoadingView.setVisibility(View.GONE);
        myWebView.setVisibility(View.VISIBLE);
    }
});
myWebView.loadUrl(...);

但所有这仅仅是一个带有进度指示器的文本和背景图像,将获得与更新的布局:

but all that was just a layout with a progress indicator text and a background image that would get updated with:

myWebView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
        myLoadingView.setText(progress+"%");
    }
});

有谁知道我可以添加这个功能到现有的PhoneGap实现,或者知道我可以代替的PhoneGap之一,我自己的实现?

Does anyone know how I can add this functionality to the existing PhoneGap implementation, or know how I can replace the PhoneGap one with an implementation of my own?

推荐答案

我想我已经找到了解决办法(而不是一个完整的解决方案,但微调的解决方案)。里面DroidGap子类,你应该加入这一行:

I think I've found a solution (not a full solution, but a spinner solution). Inside DroidGap subclass you should add this line:

super.setStringProperty("loadingDialog", "Wait, Loading...");

下面是我的完整的例子

public class MainActivity extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        super.setIntegerProperty("splashscreen", R.drawable.splash);
        // Display a native loading dialog.  Format for value = "Title,Message".  
        // (String - default=null)
        super.setStringProperty("loadingDialog", "Wait,Loading Demo...");

       super.loadUrl("file:///android_asset/www/index.html");
      }
}

有几个属性,你可以设置在本节中,请参阅本code:https://svn.apache.org/repos/asf/incubator/callback/phonegap-android/branches/WebSockets/framework/src/com/phonegap/DroidGap.java

There are several properties you could set up in this section, please see this code: https://svn.apache.org/repos/asf/incubator/callback/phonegap-android/branches/WebSockets/framework/src/com/phonegap/DroidGap.java