我在我的Android應用中添加橫幅廣告。廣告被顯示在佈局文件的設計,但它不是在應用橫幅廣告不顯示
這裏顯示的主課堂,我加入的AdView
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main_list);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.maintitlebar);
loadPage();
/*AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);*/
}
這裏是上面的Java文件的佈局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context=".MainListActivity$PlaceholderFragment"
android:padding="0dp"
>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:layout_alignParentTop="true">
</ListView>
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="@string/no_text"
/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
因此,如何在Android應用展示廣告
登錄貓錯誤以下
11-08 03:42:39.923 2519-2613/com.example.talha.appforblog W/Ads﹕ There was a problem getting an ad response. ErrorCode: 0
11-08 03:42:39.931 2519-2519/com.example.talha.appforblog W/Ads﹕ Failed to load ad: 0
你看到什麼是來自AdMob在logcat的反應?另外 - ListView是否覆蓋整個屏幕? –
是的,Listview只覆蓋整個屏幕和標題欄。我在上面的代碼中編輯了Log Cat響應。 PLease看看它 – user3585510