English 中文(简体)
需要在网上显示进步的诊断
原标题:Need to Show Progress Dialog on WebView Initial Page Load

I m 从事一个简单的、roid的仪器工作,该仪器用Ahen第8级复印机装载一个单一网站。 I m与 Java在Eclipse。 当用户在申请中点击某一网页上的一个链接时,我早就能够显示“进步”。

然而,问题在于该数字首次装满,而第一个网页装满。 网页同时使用,只显示一个空白的白色屏幕,而第1页正在装上并开始展示内容(使用安乐器进行节目制作)。 在第一页的负荷中,我要显示同样的进步指标,但在我的努力中却未能成功。

下面是我的法典。

package com.TestWebView;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.webkit.WebView;
import  android.webkit.WebViewClient;


public class TestWebView extends Activity {


    /** Called when the activity is first created. */


    @Override
public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        WebView engine = (WebView) findViewById(R.id.web_engine);

        WebViewClient myWebClient = new  WebViewClient()
        {
            ProgressDialog pd = null;

            // Override page so it s load on my view only
            @Override
            public boolean shouldOverrideUrlLoading(WebView  view, String  url)
            {
                /*view.loadUrl(url);
                return true;*/

                //start the progress dialog
                pd = ProgressDialog.show(TestWebView.this, "", "Loading...");


                 if (url.contains("maps.google.com") == true)
                 {
                    // Load new URL Don t override URL Link
                     Uri uri = Uri.parse(url);
                     Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                     startActivity(intent);
                    return true;
                 }
                 return false;
            }

            @Override
            public void onPageFinished(WebView view, String url){
                pdHandler p = new pdHandler();
                p.sendEmptyMessage(0);
            }

            class pdHandler extends Handler {
                @Override
                public void handleMessage(Message msg) {
                  if(pd != null)
                  {
                  pd.dismiss();
                  pd = null;
                  }
                }
            }

        };


        engine.getSettings().setJavaScriptEnabled(true);
        engine.getSettings().setSupportZoom(true);
        engine.getSettings().setBuiltInZoomControls(true);
        engine.setWebViewClient(myWebClient);
        engine.loadUrl("http://www.amazon.com/gp/aw/h.html");

    }


}

赞赏任何指导。

谢谢。

问题回答

使用该守则:

@Override
    public void onPageStarted(WebView view, String url, Bitmap favicon)
    {
        myLoadingDialog.show();
        super.onPageStarted(view, url, favicon);
    }
final ProgressDialog pd = ProgressDialog.show(this, "", "Loading!", true);
setContentView(R.layout.webview);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageFinished(WebView view, String url) {
        pd.dismiss();
    }
});
mWebView.loadUrl("file:///android_asset/index.html");

类似情况 这是:

   ProgressDialog pg;  
   @Override
   protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    engine.setWebViewClient(new MyWebViewClient());
    }

    public class MyWebViewClient extends WebViewClient {


    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        //WebView link Loader
        if(pg==null)
        {
            pg=new ProgressDialog(NowShowingActivity.this,R.style.MyTheme);
            pg.setMessage("Loading...");
            pg.setCancelable(false);

            pg.show();

        }

        webViewNowShowing.loadUrl(url);
        return true;

    }

    @Override
    public void onPageFinished(WebView view, String url) {

        super.onPageFinished(view, url);
        try {



            if (pg.isShowing()) {

                pg.dismiss();

                pg = null;

            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }

    }

    public MyWebViewClient() {
         super();

      }
        //initial WebPage loader
      public void onPageStarted(WebView webView, String url, Bitmap favicon) {

          if(pg==null&&pullToRefresh==false){

          pg =new ProgressDialog(NowShowingActivity.this,R.style.MyTheme);
          pg.setMessage("Loading..");
          pg.setCancelable(false);

          pg.show();

          }
      }
     }      




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签