1画面に2つのWebサイトを表示できるwebviewアプリを作ろうとしています。しかし、アプリを実行すると、1 つの Web サイトが表示され、新しいブラウザーで開きます。どうすれば 2 つの Web サイトを表示できますが、新しいブラウザーでは機能しませんか? これは私の WebViewActivity クラスです:
package com.mkyong.android;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebViewActivity extends Activity {
private WebView webView1, webView2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView1 = (WebView) findViewById(R.id.webView1);
webView1.getSettings().setJavaScriptEnabled(true);
webView1.loadUrl("http://www.google.com");
webView2 = (WebView) findViewById(R.id.webView2);
webView2.getSettings().setJavaScriptEnabled(true);
webView2.loadUrl("http://www.google.com");
}
}
これは私のxmlファイルです:
<?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/webview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.39" />
<WebView
android:id="@+id/webview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.53" />
</LinearLayout>