how to show loading while webpage is loading in blackberry eclipse webview

51 Views Asked by At

i need to show a loading bar or a message while buffering in blackberry webview. Below is my code for 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

There are 1 best solutions below

0
Kevin On

You can check out BrowserFieldListener, and combine it with whatever loading indicator you want. The easiest would be to just put a gif at the bottom of the screen. I'm not entirely sure when exactly each callback is fired, but I haven't seen downloadProgress fired reliably enough to put in an actual progress bar. I could be wrong though.

The following is an example of how the listener would look:

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);
        }
    });