我尝试在一个活动中显示多个网页浏览,但一次只显示一个。
这是我的activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_showdata"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.rober.******.showdata">
<WebView
android:id="@+id/amazon_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<WebView
android:id="@+id/homedepot_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="186dp" />
<WebView
android:id="@+id/target_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/homedepot_product"
android:layout_alignParentStart="true"
android:layout_marginBottom="39dp" />
<WebView
android:id="@+id/lowes_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="34dp"
android:layout_above="@+id/target_product"
android:layout_alignParentStart="true" />
<WebView
android:id="@+id/meijer_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/amazon_product"
android:layout_alignParentStart="true"
android:layout_marginTop="35dp" />
<WebView
android:id="@+id/walmart_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/meijer_product"
android:layout_alignParentStart="true"
android:layout_marginTop="43dp" />
</RelativeLayout>
这是main.java文件
if (amazonproduct != null) {
WebView wview = (WebView) findViewById(R.id.amazon_product);
wview.loadData(amazonproduct, "text/html", null);
Log.i("amazonproduct", "vaild info");
}
else {
WebView wview = (WebView) findViewById(R.id.amazon_product);
wview.loadData("<p> Product Not Found On Amazon</p>", "text/html", null);
Log.i("amazonproduct", " invalid vaild info");
}
if (walmartproduct != null) {
WebView wview2 = (WebView) findViewById(R.id.walmart_product);
wview2.loadData(walmartproduct, "text/html", null);
Log.i("walmartproduct", "vaild info");
}
else {
WebView wview2 = (WebView) findViewById(R.id.walmart_product);
wview2.loadData("<p> Product Not Found On Walmart</p>", "text/html", null);
Log.i("amazonproduct", " invalid vaild info");
}
如上所述,只显示了1个视图。是我的.xml或我的java活动中的错误吗?