开发者

Android admob xml issue

I have a simple problem with admob here...

I've tried all resources to add admob on my android app but somehow, when i try to add this code to the layout xml:

<Linearlayout
       ......./>

       <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"
       />

it says, The prefix "myapp" for attribute "myapp:backgroundColor" associated with an element type "com.admob.android.ads.AdView" is not bound

what's wrong?

I've add the attrs.xml:

<?xml version="1.0" encoding="utf-8"?>
    <resources>
<declare-styleable name="com.admob.android.ads.AdView开发者_如何转开发">
    <attr name="backgroundColor" format="color" />
    <attr name="primaryTextColor" format="color" />
    <attr name="secondaryTextColor" format="color" />
    <attr name="keywords" format="string" />
    <attr name="refreshInterval" format="integer" />
</declare-styleable>
       </resources>

and also the xmlns:myapp="http://schemas.android.com/apk/res/com.suit.AdmobTest" in my manifest...

THanks!


You must add the myapp namespace to the root element of your layout file. In you case to the LinearLayout element. The element then has to namespace references. The standard Android reference xmlns:android="http://schemas.android.com/apk/res/android" and your myapp reference xmlns:myapp="http://schemas.android.com/apk/res/com.suit.AdmobTest".

This should do the job.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜