I am having some problem for the following layout. The layout is very simple, just using tablelayout with 3 buttons in a row (view = landscape). However there is a "java.lang.NullPointerException " in the preview screen. I have tested and find that it is arised from the ad part, ie. if I delete the ad part, this java.lang.NullPointerException will disappear.
My questions are:
Does ad does not support landscape? Or how to modify the below code?
I would also adopt a interstitialAd. Does interstitialAd support landscape too?
Coding as follows:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:background="@drawable/bgd2" >
<TableRow
android:id="@+id/tableRow3"
android:layout_weight="0.5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonA"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_span="4"
android:background="@drawable/green_btn"
android:onClick="buttonA_click"
android:text="1,2,3"
android:textSize="20dp" />
<Button
android:id="@+id/buttonB"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_span="4"
android:background="@drawable/blue_btn"
android:onClick="button_Email_click"
android:text="abc!"
android:textSize="20dp" />
<Button
android:id="@+id/buttonC"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_span="4"
android:background="@drawable/orange_btn"
android:onClick="buttonC_click"
android:padding="2dp"
android:text="Pictures!"
android:textSize="20dp" />
</TableRow>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="@android:color/black"
android:text="Ads Unavailable"
android:textStyle="bold|italic"
ads:adUnitId="abc123"
ads:adSize="BANNER"
ads:refreshInterval="15000"
ads:loadAdOnCreate="true"/>
</TableLayout>