android - Keep current page rendered until the next page is loaded -
I have a simple app that is based on WebView.loadUrl ("").
The user clicks the URL, the default behavior is to show an empty page immediately, wait until the page is loaded, and then show this page.
I managed to show a splash screen instead of a blank page. However, is it possible to render the current page instead, and the next page should be presented only when it is fully loaded?
is it, I think, a hacking solution, I temporarily decide it That someone posts "real" way to "do this"
Main activity category:
increases the main activity of the public class activity {WebView webView1, webView2; EditText EditTatch; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); EditText = Find (edit text) UVID (RID edit_URL); WebView1 = (webview) Find VVBIID (Raid.WebView_1); WebView2 = (Webview) ViewById (R.id.webView_2); WebView1.setWebViewClient (customer); WebView2.setWebViewClient (customer); WebView1.loadUrl (. EditText.getText () toString ()); } Private WebViewClient Customer = New WebViewClient () {Public Zero onPageFinished (WebView WebView, string URL) {if (WebView == webView1) webView2.setVisibility (View.GONE); Other webview 1.Set visibility (see gene); WebView.setVisibility (View.VISIBLE); Toast. Make Text (Main Activity: This, "Webview" + (Webview == Webview 1 ?, "One": "Two") + "Showing", 0). Show (); }}; Private Zero Load URL (string url) {if (webView1.getVisibility () == see GONE) webView1.loadUrl (url); Else webView2.loadUrl (url); } Click Public Zero (see V) {loadUrl (editText.getText (). ToString ()); }}
main.xml :
& lt; LinearLayout xmlns: Android = "http://schemas.android .com / apk / res / android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical" & gt; & Lt; Android.webkit.WebView Android: id = "@ + id / webView_1" Android: layout_width = "match_parent" android: layout_height = "0dp" android: layout_weight = "1" /> & Lt; Android.webkit.WebView Android: id = "@ + id / webView_2" Android: layout_width = "match_parent" android: layout_height = "0dp" Android: layout_weight = "1" Android: visibility = "gone" /> & Lt; LinearLayout Android: layout_width = "match_parent" Android: layout_height = "wrap_content" & gt; & Lt; Android: layout_heid = "wrap_content" android: layout_weight = "4" android: layout_gravity = "center_vertical" android .example.com "/> & Lt; Android: id = "@ + id / button_load" Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: onClick = "onClick" Android: text = "load" /> & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;
Comments
Post a Comment