本文介绍了XML或Java关键字在Android中的Admob的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我似乎无法找到有关的关键字,通过XML或Java的AdMob广告的坚如磐石的文件。我试着看到线程的方法,但都失败在这两个方面。我的失败对每个案例如下。

I can't seem to find any rock solid documentation on setting keywords for adMob ads via XML or Java. I've tried the methods seen in this thread, but have failed in both respects. My failures for each case are below.

在尝试使用方法setKeywords(),setSearchQueary(),或requestFreshAd()从AD浏览报类,它像Eclipse不承认,这些方法都是AD浏览报类的一部分。难道我被不恰当实例化这个类呢?我的Java code是如下:

When trying to use methods setKeywords(), setSearchQueary(), or requestFreshAd() from the AdView class, it's like Eclipse doesn't recognize that those methods are part of the AdView class. Could I be instantiating this class improperly? My java code is below:

import com.google.ads.AdRequest;
import com.google.ads.AdView;

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

如果我尝试调用上述方法,(如adView.setKeywords()),Eclipse不识别的方法。我究竟做错了什么?

If I try to call the aforementioned methods, (eg. adView.setKeywords() ), Eclipse doesn't recognize the methods. What am I doing wrong?

当我试图通过XML来设置关键词,code似乎运行正常,但我没有得到一个添加任何有效的请求。日志返回一个没有广告,以显示的消息。在这种情况下,我不知道如果我只是没有得到结果,从我的关键字,或者如果我不设置关键字字符串正确。

When I attempt to set the keywords via XML, the code seems to run ok, but I don't get any valid requests for an add. The log returns with a "No ad to display" message. In this case, I don't know if I'm just not getting a result from my keywords or if I'm not settings the keyword string correctly.

下面描述我是如何通过XML设置的关键字:

The following depicts how I'm setting the keywords via XML:

...在attrs.xml:

...in 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"/>
   <attr name="test" format="boolean"/>
   <attr name="keywords" format="string"/>
  </declare-styleable>
 </resources>

在layout.xml ....

in layout.xml....

    <com.google.ads.AdView android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_gravity="bottom"
        android:layout_height="wrap_content"
        ads:adUnitId="blahblahblhal"
        ads:adSize="BANNER"
        ads:test="true"
        ads:keywords="farts cheese stink pooper"/>

显然,这些都不是我使用的关键字,但我设置的关键字的语法是相同的,因为我一直在使用。

Obviously, these are not the keywords I'm using, but the syntax by which I set the keywords is the same as I've been using.

如果没有广告显示是不是因为我用太多的关键字,不正确的语法,而如果我想用一个关键字短语来代替?我怎么会去这样做?

If there is no ad to display is it because I'm using too many keywords, improper syntax, and what if I want to use a phrase instead of a keyword? How would I go about doing that?

如果没有对AdMob的网站关于这一点,我表示歉意文档。但即便如此,他们把它pretty的该死很难找到。

If there is documentation on the AdMob site pertaining to this I apologize. But if so, they made it pretty damn hard to find.

感谢

推荐答案

setKeywords 是一个方法 AdRequest 类,而不是 AD浏览报

setKeywords is a method of the AdRequest class, not AdView.

AdRequest request = new AdRequest();
Set<String> keywords = new HashSet<String>();
keywords.add("keyword1");
keywords.add("keyword2");
request.setKeywords(keywords);
adView.loadAd(request);

这篇关于XML或Java关键字在Android中的Admob的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:46