2011-05-01 23 views
0

Googleが提供するサンプルコードにadmob広告を表示するには、http://code.google.com/mobile/ads/docs/android/fundamentals.htmlで成功しましたが、自分のアプリについては表示されません。admob広告が表示されない

私はいくつかの関連する質問を読んだことがありますが、私が使用しているLinearLayoutの問題ではないようです。注目すべきは、私のアプリではActivityの代わりにListActivityを拡張していることです。

<?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.mypackage.myapp" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2"> 

     <com.google.ads.AdView android:id="@+id/adView"       
      android:layout_width="wrap_content"       
      android:layout_height="fill_parent"       
      ads:adUnitId="myadmobid"       
      ads:adSize="BANNER"/> 
    </LinearLayout> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2"> 
     <TextView 
      android:id="@+id/hottopictab" 
      android:text="Deal" 
      android:gravity="center_horizontal|center_vertical" 
      android:background="#000000" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:textStyle="bold" 
     android:typeface ="sans" 
      android:layout_weight="1"/> 

     <TextView 
      android:id="@+id/newtopictab" 
      android:text="()" 
      android:gravity="center_horizontal|center_vertical" 
      android:background="#000000" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:textStyle="bold" 
     android:typeface ="sans" 
      android:layout_weight="1"/> 

     <TextView 
      android:id="@+id/recommendtab" 
      android:text="" 
      android:gravity="center_horizontal" 
      android:background="#000000" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"/> 

    <ImageButton 
      android:layout_height="fill_parent" 
      android:id="@+id/refresh" 
      android:background="#000000" 
      android:src="@drawable/refresh"  
      android:layout_width="wrap_content" 
      android:layout_marginRight="6dip"  
     /> 


    </LinearLayout>    
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="40"> 

     <ListView 
      android:id="@android:id/list" 
      android:text="row one" 
      android:textSize="15pt" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"/> 

    </LinearLayout>  
</LinearLayout> 

答えて

2

問題が解決しました。十分なスペースがないために「広告を表示するのに十分なスペースがありませんでした!」と言われました:希望:< 480,75>、持っています:< 336、522> "エミュレータを大きくすると動作します。

1

admobをテストアカウントに設定します。 AdMobの問題かコードの問題かどうかを確認できます。

また、[ログキャスト]をオンにすると、現在のところ広告が表示されない場合があります。

+0

私はテストアカウントとして設定しました。 request.setTesting(true);そして、私は自分のアプリケーションを実行/デバッグする時に私のadmodアカウントが時々新しいリクエストを受け取るのを見る。どうすればlogcatをチェックできますか? – Yang

+0

EclipseのDDMSビューのlogcatタブを確認してください。 – Haphazard

4

あなたの広告を作成するアクティビティ/メソッドを使用しているときは、logCatを確認してください。私はバナーが50dipの垂直スペースを必要とするために表示されない問題を抱えていましたが、50px(同じものではない)しか与えていませんでした。 LogCatは要求されたスペースに収まらないという警告を表示します。

また、あなたはどこかにあなたの活動の

AdView adView = (AdView)this.findViewById(R.id.adView); 
     adView.loadAd(new AdRequest()); 

を呼び出していますか?あなたは広告を要求しなければなりません、彼らは自動的に読み込まれません。

また、レイアウトに広告を配置するには、adMobチュートリアルのようなattrs.xmlファイルがあることを確認する必要があります。

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

数時間前にAdmobを実装したときにこの問題が発生しました。

私がしたことは、私のadmobアカウントに入って、アプリケーションが未入荷の在庫のための「ハウス広告」を提供するように設定しました。

私は偽の社内広告を設定しています(後者は、広告以外のバージョンの広告を購入することになります)。

これは、あなたがあなたのアプリからadmobから広告をリクエストしており、現在のところ要求がない場合は、代わりに社内広告が表示されることを意味します。

希望します。

0

ちょうど30分待ってくれました。私は、アプリケーションを再起動し、追加が表示されます。

関連する問題