Kotlin override WebView

I am new to Kotlin.

I try to create custom Error page in WebView.

Something like this in onCreate:

myWebView.webViewClient = WebViewClient() {
    override fun onReceivedError(
        view: WebView?,
        request: WebResourceRequest?,
        error: WebResourceError?
    ) {
        myWebView.loadUrl("file:///android_asset/error.html")
    }
}

If I try this outside onCreate:

override fun onReceivedHttpError (view: WebView, request: WebResourceRequest, errorResponse: WebResourceResponse) {
    myWebView.loadUrl("file:///android_asset/error.html")
}

I got this error: "overrides nothing"

Can someone help me to the right direction?

Thanks,



Read more here: https://stackoverflow.com/questions/64856935/kotlin-override-webview

Content Attribution

This content was originally published by Zoltan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: