私はこのレイアウトを作成します:
[ウェブビュー]
[編集テキスト][ボタン]
これは私のレイアウトコードです最初に幅と高さでレイアウトを宣言します:fill_parent webviewのレイアウトを宣言した後そして最後に、EditTextとボタンのレイアウトを宣言します:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#3b3b3b"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#3b3b3b"
android:gravity="center_horizontal"
android:orientation="vertical" >
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:background="#3b3b3b"
android:gravity="center"
android:textSize="20dip"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#3b3b3b"
android:layout_marginTop="20dip"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<EditText
android:id="@+id/Response"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:ems="10" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
アクティビティを起動すると、アプリケーションがクラッシュします:(
11-22 16:10:08.036: E/AndroidRuntime(675): FATAL EXCEPTION: main
11-22 16:10:08.036: E/AndroidRuntime(675): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lgc/com.example.lgc.MyActivity}: java.lang.ClassCastException: android.widget.EditText cannot be cast to android.webkit.WebView
何が問題ですか ?