一.WebView
Webview 是一个基于webkit的引擎,可以解析DOM 元素,展示html页面的控件,我们可以通过WebView来访问网页。
1.基本使用:
- 访问网页: webView.loadUrl(“http://www.baidu.com”);
- 设置为通过WebView显示网页,否则系统默认会通过手机中的浏览器打开网页:
wb.setWebViewClient(new WebViewClient());
2.最简单的demo:
activity_main.xml文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
MainActivity.java文件:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate