2015-10-20 71 views

回答

14

橫走API推出了自己的名字爲每個組件嵌入XWalkView。不僅WebView重命名爲XWalkView,而且WebViewClient也有其對應名爲XWalkResourceClientWebChromeClient - XWalkUIClient。所以,而不是setWebViewClient您應該使用setResourceClient方法並將XWalkResourceClient實例傳遞給它。在這個對象中,您可以實現一些必需的方法,例如onLoadFinished。請諮詢Cross Walk API documentation瞭解更多詳情。

3

WebViewClient例如:

webView.setWebViewClient(new WebViewClient() { 
     @Override 
     public void onPageFinished(WebView view, String url) { 
      super.onPageFinished(view, url); 
      //Do stuff 
     } 
    }); 

同樣的事情,但使用XWalkView版本:

xWalkView.setResourceClient(new XWalkResourceClient(xWalkView){ 
     @Override 
     public void onLoadFinished(XWalkView view, String url) { 
      super.onLoadFinished(view, url); 
      //Do Stuff 
     } 
    }); 
0

可以使用ResourceClient。

class ResourceClient extends XWalkResourceClient { 
    public ResourceClient(XWalkView xwalkView) { 
     super(xwalkView); 
    } 

    public void onLoadStarted(XWalkView view, String url) { 
     mProgress = (ProgressBar) findViewById(R.id.progressBar); 
     mProgress.setVisibility(View.VISIBLE); 
     super.onLoadStarted(view, url); 
     Log.d("INFO", "Load Started:" + url); 
    } 

    public void onLoadFinished(XWalkView view, String url) { 
     super.onLoadFinished(view, url); 
     Log.d("INFO", "Load Finished:" + url); 
     bottomBar = (BottomBar) findViewById(R.id.bottomBar); 
     mProgress = (ProgressBar) findViewById(R.id.progressBar); 
     mProgress.setVisibility(View.GONE); 
    } 

    public void onProgressChanged(XWalkView view, int progressInPercent) { 
     super.onProgressChanged(view, progressInPercent); 
     Log.d("INFO", "Loading Progress:" + progressInPercent); 
     mProgress = (ProgressBar) findViewById(R.id.progressBar); 
     mProgress.setProgress(progressInPercent); 
    } 
相關問題