Android Phase 27th-WebView

Source: Internet
Author: User

Create a new project yourself and get it:

Activity

Public class school_ggtz extends activity {private webview webview;private  string url;private imageview iv_school_title;private textview tv_school_content ;p rivate progressdialog dialog; @Overrideprotected  void oncreate (bundle  Savedinstancestate)  {// todo auto-generated method stubsuper.oncreate ( Savedinstancestate); Setcontentview (R.LAYOUT.ACTIVITY_SCHOOL_XXGK);iv_school_title =  (ImageView)  findviewbyid (R.id.iv_school_title); Iv_school_title.setonclicklistener (New view.onclicklistener ()  {@Overridepublic  void onclick (view arg0)  {finish ();}); tv_school_content =  (TextView)  findviewbyid (r.id.tv_school_content); Tv_school_content.settext ( Getresources (). getString (R.string.school_ggtz_content));webview =  (WebView)  findviewbyid ( R.id.id_webview); Url = getresources (). getString (R.STRING.SCHOOL_GGTZ); WEBVIew.loadurl (URL); webview.setwebviewclient (New webviewclient ()  {@Overridepublic  boolean  Shouldoverrideurlloading (webview view, string url)  {view.loadurl (URL); return true;}); Websettings settings = webview.getsettings (); Settings.setsupportzoom (true); Settings.setbuiltinzoomcontrols (True); Settings.setdisplayzoomcontrols (false); //  Hides the WebView zoom button Settings.setusewideviewport (true); Settings.setloadwithoverviewmode (true); Settings.setjavascriptenabled (True); Settings.setcachemode (websettings.load_cache_else_network); Webview.setwebchromeclient (New webchromeclient ()  {@Overridepublic  void onprogresschanged ( webview view, int newprogress)  {// todo auto-generated method stub//  newprogress 1-100 integer if  (newprogress == 100)  {//  Web page loading complete, Close Progressdialogclosedialog ();}  else {//  Web page is loading, open progressdialogopendialog (newprogress);}} PrivaTe void closedialog ()  {// TODO Auto-generated method stubif  (dialog  != null && dialog.isshowing ())  {dialog.dismiss ();d ialog = null;}} Private void opendialog (int newprogress)  {// todo auto-generated method  stubif  (dialog == null)  {dialog = new progressdialog (school_ggtz.this );d Ialog.settitle ("Loading");d Ialog.setprogressstyle (progressdialog.style_horizontal);d ialog.setprogress ( newprogress);d ialog.show ();}  else {dialog.setprogress (newprogress);}});}}

Xml:

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" @color/whit        E "android:orientation=" vertical "> <include layout=" @layout/activity_school_title "/> <webview        Android:id= "@+id/id_webview" android:layout_width= "match_parent" android:layout_height= "Match_parent" Android:scrollbars= "None"/></linearlayout>

: PS: Can be scaled, and support double-click Max, Support script.



This article is from the "Liangxiao Technology Center" blog, please be sure to keep this source http://liangxiao.blog.51cto.com/3626612/1604052

Android Phase 27th-WebView

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.