2011-03-09 84 views
0

当我尝试将AdMob广告参考放在选项卡式视图上方时,出现“解析XML文件时出错:未绑定前缀”。任何想法如何解决这个问题?在TabbedView上添加AdMob广告?

<?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> 

回答

2

您使用此:

myapp:backgroundColor 

,但我没有看到 'MYAPP' 前缀的任何声明。所以这可能是错误的根源。

就像“机器人”命名空间是这样的XML声明:

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

的“MYAPP”命名空间应该有地方还

+0

当然你是对的,我完全错过了它。 *感叹*谢谢。这是与项目之间的工作问题... xmlns:myapp =“http://schemas.android.com/apk/res/com.package.namespace” – 2011-03-09 16:43:41

+1

:)你为什么认为我知道它 - >已经完成了我的工作这个的份额;)....主要不是声明android:前缀,或声明它太迟:) – Nanne 2011-03-09 16:47:29

1

This answer似乎与声明。

正如Nanne所说,您需要正确设置xmlns以及在res/style/attrs.xml中定义的属性。

xmlns似乎是:

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

有关示例attrs.xml,检查出答案的上方。

+0

也正确。幸运的是,我正在修改我的现有项目,使其具有选项卡式界面,因此attrs.xml已经存在。否则肯定会绊倒我。 – 2011-03-09 20:39:58