0

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>
Bill Mote
  • 12,644
  • 7
  • 58
  • 82

2 Answers2

2

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

Nanne
  • 64,065
  • 16
  • 119
  • 163
  • Of course you're right and I completely missed it. *sigh* Thank you. That's the problem with working between projects ... xmlns:myapp="http://schemas.android.com/apk/res/com.package.namespace" – Bill Mote Mar 09 '11 at 16:43
  • 1
    :) Why do you think I knew it -> Have done my share of this ;) .... mostly not declaring the android: prefix, or declaring it too late :) – Nanne Mar 09 '11 at 16:47
1

This answer seems related.

You need both the xmlns set correctly, as Nanne said, as well as your attributes defined in res/style/attrs.xml.

The xmlns appears to be:

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

For an example attrs.xml, check out the answer above.

Community
  • 1
  • 1
Matthew
  • 44,826
  • 10
  • 98
  • 87
  • Also correct. Fortunately I was modifying my existing project to have a tabbed interface so the attrs.xml already exists. Would have certainly tripped me up otherwise. – Bill Mote Mar 09 '11 at 20:39