1.添加联网权限
<uses-permission android:name="android.permission.INTERNET" />
//实例化WebView对象
webview = new WebView(this);
//设置WebView属性,能够执行Javascript脚本
webview.getSettings().setJavaScriptEnabled(true);
//加载需要显示的网页
webview.loadUrl("http://www.baidu.com/");
//设置Web视图
setContentView(webview)
方式二
<?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:orientation="vertical">
<WebView
android:id="@+id/pageWeb"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></WebView>
<Button
android:id="@+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="解析视频" />
</LinearLayout>