Code example for WebView

Methods: clearView, getContext, setDrawingCacheEnabled, setTag

0
	} 
 
	public void load(String url) {
		this.url = url;
 
		wv.clearView();
		wv.setTag(url);
 
		if (android.os.Build.VERSION.SDK_INT <= 10) {
			wv.setDrawingCacheEnabled(true);
		} 
 
		fixWebviewTip(wv.getContext());
 
		WebSettings ws = wv.getSettings();
		ws.setSupportZoom(zoom);
		ws.setBuiltInZoomControls(zoom);
 
		if (!control) {
			disableZoomControl(wv);
		} 
 
		ws.setJavaScriptEnabled(true);
		ws.setAllowFileAccess(true);
		if (android.os.Build.VERSION.SDK_INT >= 11)
			ws.setAllowContentAccess(true);
		ws.setCacheMode(WebSettings.LOAD_DEFAULT);
		wv.setBackgroundColor(color);
 
		if (splash != null) {
			splash.setVisibility(View.VISIBLE);
			wv.setVisibility(View.INVISIBLE);
		} 
 
		if (wv.getWidth() > 0) {
			setup(); 
		} else { 
			delaySetup(); 
		} 
 
	} 
 
	public void reset() { 
		this.url = null;
		if (splash != null) {
			splash.setVisibility(View.VISIBLE);
			wv.setVisibility(View.INVISIBLE);
		} 
	} 
 
	private void delaySetup() { 
		wv.setPictureListener(new PictureListener() {
 
			@Override 
			public void onNewPicture(WebView view, Picture picture) {
				wv.setPictureListener(null);
				setup(); 
			} 
 
		}); 
 
		wv.loadData("<html></html>", "text/html", "utf-8");
		wv.setBackgroundColor(color);
 
	} 
 
	private void setup() { 
		String source = getSource(wv.getContext());
		String html = source.replace("@src", url).replace("@color",
				Integer.toHexString(color));
 
		wv.setWebViewClient(this);
 
Experience pair programming with AI  Get Codota for Java