android.webkit.WebView.clearView()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(303)

本文整理了Java中android.webkit.WebView.clearView()方法的一些代码示例,展示了WebView.clearView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.clearView()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:clearView

WebView.clearView介绍

暂无

代码示例

代码示例来源:origin: androidquery/androidquery

/**
 * Clear a view. Applies to ImageView, WebView, and TextView.
 *
 * @return self
 */
public T clear(){
  
  if(view != null){
    
    if(view instanceof ImageView){
      ImageView iv = ((ImageView) view);
      iv.setImageBitmap(null);
      iv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof WebView){
      WebView wv = ((WebView) view);
      wv.stopLoading();
      wv.clearView();
      wv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof TextView){
      TextView tv = ((TextView) view);
      tv.setText("");
    }
    
    
  }
  
  return self();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldRecordClearView() {
 assertThat(shadowOf(webView).wasClearViewCalled()).isFalse();
 webView.clearView();
 assertThat(shadowOf(webView).wasClearViewCalled()).isTrue();
}

代码示例来源:origin: stackoverflow.com

@Override
public void onReceivedError(WebView view, int errorCode,
  String description, String failingUrl) {
  view.clearView();
}

代码示例来源:origin: apps4av/avare

@Override
  public Object callback(Object obj1, Object obj2) {
    int pos = (int)obj2;
    if (0 == pos) {
      mWebView.clearView();
    } else {
      mWebView.loadUrl("https://apps4av.net/ads/" + pos + ".php");
    }
    return null;
  }
});

代码示例来源:origin: stackoverflow.com

private ViewGroup mScrollView //linearlayout encapsuled in a scrollView;
private WebView mWebView;

private Handler mHandler = new Handler(){      
 public void handleMessage(Message msg){
  mWebView.reload();
  mScrollView.addView(mWebView, 0);
 }
};

private updateWebView(){
 //update the content of your web view
 mScrollView.removeView(mWebView);
 mWebView.clearView();
 mHandler.sendMessageDelayed(mHandler.obtainMessage(0), 200);
}

代码示例来源:origin: stackoverflow.com

if (urlPath
       .compareToIgnoreCase(Const.defURL) == 0) {
   } else {
     mWebView.setWebViewClient(new WebViewClient() {
       @Override
       public boolean shouldOverrideUrlLoading(WebView view, String url) {
         view.clearView();
         view.loadUrl(url);
         return true;
       }
     });
   }

代码示例来源:origin: stackoverflow.com

final WebView wbView = (WebView) findViewById(R.id.WebView);

wbView.getSettings().setJavaScriptEnabled(true); 
wbView.loadUrl("https://play.google.com/store/apps");
wbView.clearView();
wbView.measure(100, 100);
wbView.getSettings().setUseWideViewPort(true);
wbView.getSettings().setLoadWithOverviewMode(true);

代码示例来源:origin: stackoverflow.com

WebView img = (WebView) findViewById(R.id.webview);
 img.clearView();
 img.clearCache(true);
 img.getSettings().setBuiltInZoomControls(true);
 img.getSettings().setSupportZoom(false);
 img.loadUrl(image);

代码示例来源:origin: andforce/iBeebo

public void refresh() {
  mWebView.clearView();
  mWebView.loadUrl("about:blank");
  mWebView.stopLoading();
  String url = buildOAuthUrl();
  mWebView.loadUrl(url);
  DevLog.printLog("OAUTH_ACTIVITY-refresh:", "" + url);
}

代码示例来源:origin: com.googlecode.android-query/android-query

/**
 * Clear a view. Applies to ImageView, WebView, and TextView.
 *
 * @return self
 */
public T clear(){
  
  if(view != null){
    
    if(view instanceof ImageView){
      ImageView iv = ((ImageView) view);
      iv.setImageBitmap(null);
      iv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof WebView){
      WebView wv = ((WebView) view);
      wv.stopLoading();
      wv.clearView();
      wv.setTag(AQuery.TAG_URL, null);
    }else if(view instanceof TextView){
      TextView tv = ((TextView) view);
      tv.setText("");
    }
    
    
  }
  
  return self();
}

代码示例来源:origin: stackoverflow.com

@Override
public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
         //Clearing the WebView
         try {
           webView.stopLoading();
         } catch (Exception e) {
         }
         try {
           webView.clearView();
         } catch (Exception e) {
         }
         if (webView.canGoBack()) {
           webView.goBack();
         }
         webView.loadUrl("about:blank");
         //Showing and creating an alet dialog
         AlertDialog alertDialog = new AlertDialog.Builder(youractivity.this).create();
         alertDialog.setTitle("Error");
         alertDialog.setMessage("No internet connection was found!");
         alertDialog.setButton("Again", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             finish();
             startActivity(getIntent());
           }
         });
         alertDialog.show();
         //Don't forget to call supper!
         super.onReceivedError(webView, errorCode, description, failingUrl);
       }

代码示例来源:origin: stackoverflow.com

protected void onPostExecute(String S) {
   mWebView.setWebViewClient(new WebViewClient() { 
     @Override
     public void onReceivedError(WebView view, int errCode, String errDescription, String failingUrl ) {
       try {
           view.stopLoading();
        } 
       catch(Exception e){}
       view.clearView();
       Toast.makeText(getApplicationContext(), "Error code is "+errCode, Toast.LENGTH_SHORT).show();
       if(errCode == -2 || errCode == -8) {
         view.loadData("There seems to be a problem with your Internet connection. Please try later", "text/html", "UTF-8");
       }
       if(errCode == -14) {
         view.loadData("Page cannot be found on server", "text/html", "UTF-8");
       }
     }
   });
   mWebView.loadUrl(url);
   ShowProgress.dismiss();
 }

相关文章

WebView类方法