web pages, rather than local implementation, there are many benefits, such as the interface changes do not need to redistribute a new version, directly on the server side to modify the line. Use Web pages to show the interface, typically, there is more or less interaction with Java code, such as clicking on a button on the page, we need to know the button click event, or we want to call a method, let the page perform some action, in order to achieve these interactions, we usually use JS to achi
Use WebView to display Web pages in the interface via intent call system browser URI uri=uri.parse (URL);//url for the linked address intent intent=new intent (Intent.action_view,uri ); StartActivity (intent);----------------------------- Course Objective: Make a simple web browser through WebView course content: (1) Add WebView to your app (2) Use the
Example one: WebView load HTML5 implement cool boot pageMost people are aware that an app's boot page is still important, but to make a very cool boot page through native Android code is relatively complex, just HTML5 in the production of Cool animation Web page Comparison to force, we might as well first use HTML5 to make mobile phone guide page, And embed it in the app.First of all, what do we need to do?
Overview:Android WebView is a special view on the Android platform that can be used to display Web pages, which can be used to display only an online page in your app and to develop a browser. WebView internal implementation is the use of the rendering engine to display the content of the view, providing Web page forward and backward, Web page zoom in, zoom out,
steps to call WebView are as follows:
(1)
Add the WebView control to your application. You only need to include the Layout of the
(2)
Use loadUrl () to load a WebView.
WebView myWebView = (WebView) findViewById(R.id.webview);myWebView.loadUrl("http://www.example.com"
Jsresult result) in JavaScript {//Build a Builder to display a dialog box in a Web pageBuilder builder = new Builder (mainacitivity.this);builder.settitle ("hint");builder.setmessage (message);Builder.setpositivebutton (Android. R.string.ok,new Alertdialog.onclicklistener () {public void OnClick (Dialoginterface dialog, int which) {result.confirm ( );}});builder.setcancelable (false);builder.create ();buil
by WebView to cache pages.Simple: you only need to enable the relevant functions for WebView settings and set the cache path for the database to complete the cache! SpecificThe following is an example of implementation ~
1. cache classification:
The first thing we need to talk about is the cache classification. The cached data is divided:Page cache and data c
view, int newprogress) {
progressbar.setprogress (newprogress);
Newprogress values are 1 to 100 integers, we can use this parameter to display the load progress ProgressBar or ProgressDialog
}
} @Override
public
Void Onreceivedtitle (WebView view, String title) {
Textview.settext (title);//argument title is the title of the Web page and can be displayed with a textView.
}
}
);
OK, let's take a look at the loading of the page.
It l
dataSetbuiltinzoomcontrols (TRUE);//settings support scalingSetsavepassword (FALSE); Set whether to save passwordSetuseragentstring ("mozilla/5.0 (IPad; U CPU os 3_2 like Mac os x;en-us) applewebkit/531.21.10 (khtml, like Gecko) version/4.0.4 mobile/7b334bsafari/531.21.10 ");// supports a variety of different devicesSteps:1. Call WebView associated websettings setjavascriptenabled (true) to enable
Android Basics Getting Started tutorial--7.5.3 Android 4.4 after webview some caveatstags (space delimited): Android Basics Getting Started TutorialIntroduction to this section:
This section refers to the original: WebView use precautions in
JavaScript * Setlayoutalgorithm set layout mode setlighttouchenabled settings with mouse activation by option * Setsupportzoom settings support variable Coke **/Ws.setbuiltinzoomcontrols (true);//Hide Zoom buttonWs.setlayoutalgorithm (WebSettings.LayoutAlgorithm.NARROW_COLUMNS);//Typesetting adaptation ScreenWs.setusewideviewport (true);//can be scaled at any scaleWs.setloadwithoverviewmode (true);//the Setusewideviewport method sets the window recom
Android WebView page loading optimization, androidwebview
At present, there are more and more webapps and the experience is getting better and better. In order to better use WebView to display smooth pages, you can make the following optimizations:
WebView Cache
Resource File Local Storage
Reduce time-consuming ope
Browser controls are available in every development environment, which provides a foothold for vest magic. webbrowser for windows, webview for android and ios. However, their engines are different. Compared with Microsoft's webbrowser, android and ios's webview engines are all webkit and provide Html5 support. This art
its most basic function.③ and JS interaction. (If your JS base is better than the Java base, it's a good choice to do some complex processing in this way.)3. How to use WebView?Here directly with an SVN take off the demo, first on the demo after the explanation. The chart of the demo is as follows:Webviewdemo.javaPackage Com.google.android.webviewdemo;Import android.app.Activity;Import Android.os.Bundle;Import Android.os.Handler;Import Android.util.L
WebViewA Brief introduction:WebView is generally used to show the HTML of the Android page, we generally call it HTML5 development;WebView can make the Web page easy to embed into the app, but also can directly with JS call each other, through JSON or Gson format data call, can be very convenient and background interaction.WebView has two methods:setwebchromeclient and setwebclientSetwebclient: Mainly deal
Android WebView page loading Optimization
At present, there are more and more webapps and the experience is getting better and better. In order to better use WebView to display smooth pages, you can make the following optimizations:WebView cache resource file local storage reduces time consumption operation client UI Optimization
Some may say, why not make it na
object (WebViewClient) to WebView, and rewrite the shouldOverrideUrlLoading method webview. setWebViewClient (new MyWebViewClient ());
Step 2: Add a listener object
private class MyWebViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) {view.loadUrl(url); return true;};}
2. scroll bar settings
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.