2 つの webView を並べて含む単純なアクティビティを作成しました。次のコードを使用してそれらを開始します。
setContentView(R.layout.detail); //xml layout that contains two webviews
webView1 = (WebView) this.findViewById(R.id.webView1);
webView2 = (WebView) this.findViewById(R.id.webView2);
webView1.setWebChromeClient(new WebChromeClient());
webView1.loadUrl("http://www.google.com");
webView2.setWebChromeClient(new WebChromeClient());
webView2.loadUrl("http://www.google.com");
問題は、上記のコードで webView1 が正常に読み込まれるのに対し、webView2 は常に空白 (白いボックスのみ) であり、その理由がわかりません。
ここに私のxmlファイルがあります
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip" >
<WebView
android:id="@+id/webView2"
android:layout_width="470dp"
android:layout_height="300dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
<WebView
android:id="@+id/webView1"
android:layout_width="470dp"
android:layout_height="300dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/webView1"
android:layout_alignParentTop="true"
android:layout_marginTop="49dp"
android:text="Cell"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/TextView01"
android:layout_alignParentLeft="true"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_marginLeft="50dp"
android:layout_toRightOf="@+id/textView2"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/TextView01"
android:layout_alignLeft="@+id/TextView01"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/webView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="23dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>