Previously, I learned how to use the WebView control to display Web pages in activity.
In my actual development, there is a need to use the fragment in the WebView control, then Baidu learned a bit
It's simple, but of course it's not the same as the method used in the activity.
Specific look at the code
1 Package Com.example.qunxiong;2 3 import Android.os.Bundle;4 import android.support.v4.app.Fragment;5 import Android.view.LayoutInflater;6 import Android.view.View;7 import Android.view.ViewGroup;8 import android.webkit.WebSettings;9 import Android.webkit.WebView;Ten import android.webkit.WebViewClient; One A Public classFragmentshow extends fragment{ - PrivateWebView WebView; - @Override the PublicView Oncreateview (layoutinflater inflater, ViewGroup container, - Bundle savedinstancestate) { - //TODO auto-generated Method Stub - + - + returnInflater.inflate (R.layout.web_show, container,false); A } at @Override - Public voidonviewcreated (view view, Bundle savedinstancestate) { - //TODO auto-generated Method Stub - super.onviewcreated (view, savedinstancestate); -WebView =(WebView) View.findviewbyid (R.id.webview); -WebSettings settings =webview.getsettings (); inSettings.setjavascriptenabled (true); - to + //Support Scaling -Settings.setusewideviewport (true);//Set Support viewport theSettings.setloadwithoverviewmode (true); *Settings.setbuiltinzoomcontrols (true); $Settings.setsupportzoom (true);//Set Support ZoomPanax Notoginseng - //Open URLs theWebview.loadurl ("http://www.527fgame.com/news.html"); + } A the}
You can see that line 23rd---40 is the way to use the WebView control in fragment, it's simple, just look at the annotations.
Android Development _webview How to use in fragment