I'm trying to show display custom html code whenever a `WebView` encounters an error.

It works fine except 1 unwanted behaviour: sometimes (especially when spamming) `loadUrl` briefly shows the real error page.

Here's how it looks:

[![unwanted behaviour](https://i.stack.imgur.com/drL9S.gif)](https://i.stack.imgur.com/drL9S.gif)

Does anyone know what's causing this and/or how to avoid it? Preventing the `WebView` from drawing completely until load has finished isn't wanted. That would also cause properly shown pages to "wait" until they have been fully loaded.

Code to re-create the problem is pretty straightforward:

[activity\_main.xml](http://pastebin.com/LMBEZ42E)  

[MainActivity.java](http://pastebin.com/Xp8enV3z)