I have a webview load URL \"http://www.google.com\"..I want disable event when we click link or button in that webview..I set clickable=\"false\" but not work..
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
Create a custom WebViewClient
and override shouldOverrideUrlLoading
& shouldOverrideKeyEvent
. For example:
public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideKeyEvent (WebView view, KeyEvent event) {
// Do something with the event here
return true;
}
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
if (Uri.parse(url).getHost().equals("www.google.com")) {
// This is my web site, so do not override; let my WebView load the page
return false;
}
// reject anything other
return true;
}
}
No idea to disable HTML Native button in webview but you can disable link
public class formatHTML {
public static String changeHTMLFormat(String htmlObject){
String result = "", CSSCoding = "";
CSSCoding = htmlObject;
CSSCoding = CSSCoding.replaceAll("<[aA].*?>", "<u>");
CSSCoding = CSSCoding.replaceAll("</[aA]>", "</u>");
return CSSCoding;
}
}