记得要给WebView添加Layout_hight和Layout_width!
我查看了Logcat之后发现是没有给WebView添加高度,所以造成了闪退。
附上修正后的WebView的布局:
<WebView
android:layout_width="match_parent"
android:id="@+id/mainWebView1"
android:layout_height="match_parent"/>
附上我全部的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="
http://schemas.android.com/apk/res/android"android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="wrap_content"
android:ems="10"
android:layout_height="wrap_content"
android:id="@+id/mainEditText1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JUMP"
android:id="@+id/mainButton1"/>
</LinearLayout>
<WebView
android:layout_width="match_parent"
android:id="@+id/mainWebView1"
android:layout_height="match_parent"/>
</LinearLayout>