I searched and found similar questions, but they mostly tell how to change the contents of a webView, and not how to hide it.
My webView is initially hidden using android: visibility = "gone" in main.xml, I change it dynamically to visible using myWebView.setVisibility (1); when the page is fully loaded (and it works). Now I want to hide this webView when an error is detected. The reason I wanted to hide this is because I have a nice background in the layout that reports an error. I know that this is not the best approach for this, and probably change it later, but now I would like to decide why the web browser does not hide when an error occurs (just for fun, maybe).
Here is what I tried:
@Override
public void onReceivedError (WebView view, int errorCode,
String description, String failingUrl) {
myWebView = (WebView) findViewById(R.id.webview);
try {view.stopLoading();} catch(Exception e){}
try {view.clearView();} catch(Exception e){}
view.loadUrl("file:///android_asset/error.html");
view.setBackgroundColor(0x00000000);
view.setVisibility(View.GONE);
}
Any ideas?