android - WebView cannot load webpage inside -
I want to load the webpage inside the piece, but there is some problem.
1. Without override
isOverrideUrl loading method, the website default browser is open with Chrome.
2. When Override
shouldOverrideUrl loading , nothing happens, only new blank activity is created, this is my
onCreateView method
piece class
@Override is inside the public view preview (LayoutInflater inflater, ViewGroup container, bundled saved instance) {View resultView = inflater.inflate (R. Layout Container, Container, False) ; If (getArguments ()! = Null) {string URL = getArguments (). getString (KEY_URL); WebView productDetailView = (WebView) Results View.findViewById (R.id.webView); productDetailView.setWebViewClient (new WebViewClient () {public boolean should override URL loading (webview view, string url) {return super.shouldOverrideUrl loading (see, url);}}); ProductDetailView.loadUrl (url); } View return results; } targetSdkVersion is 19 and added INTERNET is the same as the permutation and the XML file snippet below. / p>
& lt; FrameLayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" Android: layout_width = "match_perrent" android: layout_height = "Match_perrent" tool: reference = "com.example.ProductDetailFragment" & gt; & Lt; WebView Android: layout_width = "match_parent" Android: layout_height = "match_parent" android: id = "@ + id / webview" Android: layout_gravity = "center" /> & Lt; / FrameLayout & gt; What's the problem?
Try this code
webView.setWebViewClient (new WebViewClient () {@Override Public Boolean Shoulder Override URL Loading (webview view, string url) {view.loadUrl (url); back right;}}); webView.loadUrl (url); and start your activity with FLAG_ACTIVITY_NEW_TASK
Comments
Post a Comment