2011-07-20 5 views
0

これを理解することはできません。 5つのボタンがあり、5回目はAdMob広告を表示したいだけですが、それはうまくいきません。私はとても近いです!どんな援助も感謝します以下は私のactivity.javaと私のmain.xmlアンドロイド・アドボック・ボタン

package com.CompanyName.SANDBOX; 

import android.app.Activity; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import com.google.ads.*; 

public class SANDBOXActivity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main); 

    //--> Create the adView 
    AdView adView = new AdView(this, AdSize.BANNER, "a14e27391701ceb"); 
    // Lookup your LinearLayout assuming it’s been given 
    // the attribute android:id="@+id/mainLayout" 
    Button btn5 = (Button)findViewById(R.id.btn_Button05); 
    // Add the adView to it 
    btn5.addView(adView); 
    // Initiate a generic request to load it with an ad 
    adView.loadAd(new AdRequest()); 
    //--> End AdMoB adView 
} 
} 

と私のmain.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:focusableInTouchMode="true" 
    android:orientation="vertical" 
    android:gravity="center_vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/icon" 
    android:scaleType="centerInside"> 
<Button android:id="@+id/btn_Button01" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textStyle="bold" 
    android:text="Start SANDBOX Mobile"> 
</Button> 
<Button android:id="@+id/btn_Button02" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textStyle="bold" 
    android:text="More Applications"> 
</Button> 
<Button android:id="@+id/btn_Button03" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textStyle="bold" 
    android:text="Share"> 
</Button> 
<Button android:id="@+id/btn_Button04" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:text="Send feedback"> 
</Button> 
<Button android:id="@+id/btn_Button05" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_gravity="center_horizontal"> 
</Button> 
</LinearLayout> 
+0

お困りですか? – Pengume

+0

全くエラーはありません。どのタイプの広告も表示されません。 –

+0

インターネットにアクセスする権限がありますか? – Pengume

答えて

0
AdView adview = (AdView)findViewById(R.id.adView1); 
AdRequest re = new AdRequest(); 
re.setTesting(true); 
adview.loadAd(re); 

は、おそらくこれらをインポートしようと、それは助けを願っています。です あなたのアプリのためにそれを作る必要があります。私はあまりにも最初にそれを作ることができませんでした:)

+0

「これらをインポートしようとすると」とはどういう意味ですか? AdMobに問題があることがわかったと思います。 AdMobが7月19日にLIVEをPRODUCTIONにプッシュしたバージョンに重大なバグがあります。 admob jar のサイズは約50Kで、.zip自体には説明書やpdfは含まれていません。次のURLを参照してください。 https://groups.google.com/forum/#!topic/google-admob-ads-sdk/Ys6CsvTez3I私は個人的にすでに約25時間かけて問題を解決しようとしています。 –

1

Button.AddViewのためのaddView(AdView)メソッドはレイアウトにありません。

LinearLayout layout = (LinearLayout)findViewById(R.id.lout); 
// Create the adView 
    final AdView adView = new AdView(this, AdSize.BANNER, "a14e27391701ceb"); 
    // Add the adView to it 
layout.addView(adView); 

// Initiate a generic request to load it with an ad 
AdRequest request = new AdRequest(); 

request.setTesting(true); 
adView.loadAd(request); 
関連する問題