Search code examples
androidviewadstabbed

Add an AdMob Ad above a TabbedView?


I am getting an "Error parsing XML file: Unbound prefix" when I try to put my AdMob ad reference above a tabbed view. Any ideas how to fix that?

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:padding="5dp">
        <com.admob.android.ads.AdView android:id="@+id/ad"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF"
            myapp:secondaryTextColor="#CCCCCC" />
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="wrap_content" />
        <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>

Solution

  • You're using this:

    myapp:backgroundColor
    

    but I don't see any declaration of the 'myapp' prefix. so that might be the source of the error.

    Just like the "android" namespace is declared in the xml like this:

    xmlns:android="http://schemas.android.com/apk/res/android"
    

    the 'myapp' namespace should have a declaration somewhere also