Admob是否与Android中的simple-xml集成? [英] Admob integration with simple-xml in Android?

查看:74
本文介绍了Admob是否与Android中的simple-xml集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难将Admob标语集成到我的游戏中。我使用了simple-xml-2.6.2.jar库,因为我认为它很容易实现到我的游戏中。现在,我有了一个布局文件,其中包含发布者ID和测试设备的正确代码:

I am having a hard time integrating an Admob banner into my game. I have used simple-xml-2.6.2.jar library because I considered it to be simple to implement into my game. Now I have a single layout file, with the correct code for publisher ID and test device:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     ads:adUnitId="xxxxxxxxxxx"
                     ads:adSize="BANNER"
                     ads:testDevices="TEST_EMULATOR, zzzzzzzzzzzz"
                     ads:loadAdOnCreate="true"/>
</LinearLayout>

游戏在横向模式下运行,我希望您将广告展示为横幅广告顶部或底部,但没有显示任何测试广告,而且我对此还一无所知。
感谢您的帮助!

The game runs in landscape mode, and I would like tu get the ads to show as a banner at the top or bottom, but there aren't any test ads being shown, and I haven't got any ideas as to why is that. Any help is apreciated!

推荐答案

在xml中使用以下代码说xml名称为 adview .xml

Use below code in xml say xml name is adview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/adView"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="50dip"/>

现在在活动中加载广告。

Now in your Activity load the ad.

 AdView adView = new AdView(this,AdSize.BANNER,"yourid");
 LinearLayout ll= (LinearLayout) findViewById(R.id.adView);
 ll.addView(adView);
 AdRequest ar = new AdRequest();
 ar.setGender(AdRequest.FEMALE);
 adView.loadAd(ar);

您可以在xml这样的任何活动中包含此view(xml)。 p>

You can include this view(xml) in any of your activity from xml like this..

 <include layout="@layout/adview" />  // your xml

这篇关于Admob是否与Android中的simple-xml集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆