如何在黑莓eclipse webview中加载网页时显示加载

时间:2015-03-23 05:39:53

标签: webview blackberry blackberry-eclipse-plugin

我需要在黑莓webview中缓存时显示加载栏或消息。以下是我的webview代码

  • BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
    myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
    BrowserField browserField = new BrowserField(myBrowserFieldConfig);
    add(browserField);
     browserField.requestContent("http://azontong.com/home.php?user=bb");
    

1 个答案:

答案 0 :(得分:0)

您可以查看BrowserFieldListener,并将其与您想要的任何加载指示器结合使用。最简单的方法就是在屏幕底部放一个gif。我并不完全确定每次回调的确切时间都会被触发,但我还没有看到downloadProgress被发射得足够可靠,无法放入实际的进度条。我可能错了。

以下是侦听器外观的示例:

final VerticalFieldManager statusManager = new VerticalFieldManager(USE_ALL_WIDTH);
    BitmapField loadingIndicator = new BitmapField(null, FIELD_HCENTER);
    loadingIndicator.setImage(gif);
    statusManager.add(loadingIndicator);

    browserField.addListener(new BrowserFieldListener()
    {
        public void documentAborted(BrowserField browserField, Document document) throws Exception
        {
            super.documentAborted(browserField, document);
            setStatus(null);
        }

        public void documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) throws Exception
        {
            super.documentCreated(browserField, scriptEngine, document);
            setStatus(statusManager);
        }

        public void documentError(BrowserField browserField, Document document) throws Exception
        {
            super.documentError(browserField, document);
            setStatus(null);
        }

        public void documentLoaded(BrowserField browserField, Document document) throws Exception
        {
            super.documentLoaded(browserField, document);
            setStatus(null);
        }

        public void documentUnloading(BrowserField browserField, Document document) throws Exception
        {
            super.documentUnloading(browserField, document);
            setStatus(null);
        }

        public void downloadProgress(BrowserField browserField, ContentReadEvent event) throws Exception
        {
            super.downloadProgress(browserField, event);
            setStatus(statusManager);
        }
    });