Android Development _webview How to use in fragment

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.