0

This is my code:

webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            view.loadUrl("file:///android_res/drawable/sale_screen_20170912.jpg");
        }
    });

I want to load an image from drawable resource when receiving an error from webview. But this is what I got when try to load this image from drawable folder.

enter image description here

API level of the project is 17.

TIenHT
  • 61
  • 1
  • 7

1 Answers1

1

Try this

        webView.loadDataWithBaseURL("file:///android_res/drawable/", "<img src='sale_screen_20170912.jpg' />", "text/html", "utf-8", null);
Yonatan
  • 150
  • 1
  • 9