Rick Rick - 4 months ago 12
Android Question

Is there anyway to completely disable a webview in android

I want my webview to show a webpage but not to have any interaction with the page at all.
Just show it. I an showing an iframe but when you click on the image in it it goes to a link. That link is to big for the frame. I need to disable being able to click it.

i have tried

WebView
android:id="@+id/wv_AmberAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:longClickable ="false"


and

wv_Amber_Alert.setFocusableInTouchMode(false);
wv_Amber_Alert.setFocusable(false);
wv_Amber_Alert.setOnTouchListener(null);
wv_Amber_Alert.setOnClickListener(null);

Answer

You can try attaching a WebViewClient to the WebView and override the onLoadResource() method to stop loading of the url:

WebViewClient client = new WebViewClient() {
        @Override
        public void onLoadResource(WebView view, String url) {
            view.stopLoading();
        }
    };
wv_Amber_Alert.setWebViewClient(client);
Comments