Using WebView to implement browser capabilities under Android
Source: Internet
Author: User
<span id="Label3"></p><p><p><strong>Using WebView to achieve browser functionality under Android:</strong></p></p><p><p></p></p><p><p><strong>1, interface Add WebView control.</strong></p></p><p><p><strong>2, in the Interface. The Java code page (protected void onCreate (Bundle Savedinstancestate) METHOD) adds the following code:</strong></p></p><p><p>#region<br>WebView wb= (WebView) Findviewbyid (r.id.wb_main);<br>Set the WebView property to be able to execute JavaScript scripts<br>Wb.getsettings (). setjavascriptenabled (true);<br>Load Web pages that need to be displayed<br>Wb.loadurl ("http://www.baidu.com");<br>Set up a Web view<br>When the user clicks on a link in your webview, the default behavior is that Android launches an app that handles urls, usually the default browser opens and downloads the destination Url. however, You can override this behavior in your webview so that the connection is still open in your WEBVIEW.<br>Wb.setwebviewclient (new webviewclient ());<br>#endregion</p></p><p><p></p></p><p><p><strong>3. Set up the configuration file and add code</strong></p></p><p><p><?xml version= "1.0" encoding= "utf-8"?><br><manifest xmlns:android= "http://schemas.android.com/apk/res/android"<br>Package= "com.example.hi"<br>Android:versioncode= "1"<br>Android:versionname= "1.0" ></p></p><p><p><uses-sdk<br>android:minsdkversion= "18"<br>android:targetsdkversion= "/>"</p></p><p><p><application<br>android:allowbackup= "true"<br>android:icon= "@drawable/ic_launcher"<br>Android:label= "@string/app_name"<br>Android:theme= "@style/apptheme"<br>><br><activity<br>Android:name= ". Mainactivity "<br>android:label= "@string/app_name" android:theme= "@android: style/theme.notitlebar.fullscreen" ><br><intent-filter><br><action android:name= "android.intent.action.MAIN"/></p></p><p><p><category android:name= "android.intent.category.LAUNCHER"/><br></intent-filter><br></activity><br><br></application><br><span style="color: #ff0000;"><strong><uses-permission android:name= "android.permission.INTERNET"/></strong></span><br></manifest></p></p><p><p></p></p><p><p></p></p><p><p>------------------------------------------------</p></p><p><p><strong>Usually we encounter the following problems when making a browser client:</strong></p></p><p><p><strong>1, How to make WebView full screen?</strong></p></p><p><p><strong>Locate the layout interface, Locate the main form object, and clear the padding spacing values.</strong></p></p><p><p><strong>2, How to remove the top head?</strong></p></p><p><p><strong>Locate the configuration file, Select the application tab, go to the Appliacation node layout section, and on the right, see Theme nodes, Select the "@android: style/theme.notitlebar.fullscreen" value.</strong></p></p><p><p></p></p><p><p></p></p><p><p><strong>----------------------------------------------</strong></p></p><p><p><strong>Complete the above actions and steps to implement the Android browser Client.</strong></p></p><p><p></p></p><p><p>Using WebView to implement browser capabilities under Android</p></p></span>
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.