开发者

Android admob ads not displaying

So I feel it might be a layout issue in my main.xml file. I am in no way an xml expert. I experimented with the test app from admob and was able to get it to display ads so I know it is not an issue with the publisher ID. Below is the contents of my main.xml file:

<?xml version="1开发者_运维技巧.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.project.testsoundboard"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@+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">
         <com.google.ads.AdView 
                       android:id="@+id/adView"
                       android:layout_width="320dip"
                       android:layout_height="48dip"
                      ads:adUnitId="a28d9e354361jf3"
                       ads:adSize="BANNER"/>
        <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">
            <GridView 
            android:id="@+id/tab1"
                android:layout_width="fill_parent" android:layout_height="fill_parent"
                android:padding="2dp" android:verticalSpacing="2dp"
                android:horizontalSpacing="2dp" android:numColumns="2"
                android:stretchMode="columnWidth" android:gravity="center" />
            <GridView android:id="@+id/tab2"
                android:layout_width="fill_parent" android:layout_height="fill_parent"
                android:padding="2dp" android:verticalSpacing="2dp"
                android:horizontalSpacing="2dp" android:numColumns="2"
                android:stretchMode="columnWidth" android:gravity="center" />
            <GridView android:id="@+id/tab3"
                android:layout_width="fill_parent" android:layout_height="fill_parent"
                android:padding="2dp" android:verticalSpacing="2dp"
                android:horizontalSpacing="2dp" android:numColumns="2"
                android:stretchMode="columnWidth" android:gravity="center" />
        </FrameLayout>
    </LinearLayout>
</TabHost>

Here is my attrs.xml:

 <?xml version="1.0" encoding="utf-8"?>
<resources>
 <declare-styleable name="com.google.ads.AdView">
  <attr name="adSize">
      <enum name="BANNER" value="1"/>
      <enum name="IAB_MRECT" value="2"/>
      <enum name="IAB_BANNER" value="3"/>
      <enum name="IAB_LEADERBOARD" value="4"/>
  </attr>
  <attr name="adUnitId" format="string"/>

I added the appropriate permissions in the manifest file as well

There is spacing above the tabs from the layout_width and layout_height I specified in the main.xml layout file but nothing appears.

Any help or suggestions would be greatly appreciated.


Might be that your framelayout is also trying to fill parent, so even though you explicitly gave a size for your ad, it might be getting squeezed out.

If that doesn't help, you might try removing everything except for the ad, and ad the other elements until you find what causes it to break.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜