I am trying to display multiple webviews in one activity but only one shows up at a time.
Here is my 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>
And here is the main.java file
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");
}
As I stated above, only 1 view shows up. Is the error in my .xml or my java activity?