hi
In a list view i have an webview which should load a image file from the server,when there is no image present i need a dummy image .I tried
holder.imag
I had to override WebViewClient.onReceivedHttpError() instead of WebViewClient.onReceivedError().
@Override
public void onReceivedHttpError(final WebView view, final WebResourceRequest request, WebResourceResponse errorResponse) {
final int statusCode;
// SDK < 21 does not provide statusCode
if (Build.VERSION.SDK_INT < 21) {
statusCode = STATUS_CODE_UNKNOWN;
} else {
statusCode = errorResponse.getStatusCode();
}
Log().d(LOG_TAG, "[onReceivedHttpError]" + statusCode);
}
From the WebClient documentation:
/**
* Notify the host application that an HTTP error has been received from the server while
* loading a resource. HTTP errors have status codes >= 400. This callback will be called
* for any resource (iframe, image, etc), not just for the main page. Thus, it is recommended to
* perform minimum required work in this callback. Note that the content of the server
* response may not be provided within the errorResponse parameter.
* @param view The WebView that is initiating the callback.
* @param request The originating request.
* @param errorResponse Information about the error occured.
*/
public void onReceivedHttpError(
WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
}