2

我在将 AdWhirl 集成到我的 android 应用程序时遇到了一个奇怪的问题。

通过 AdWhirl 连接的网络:
* Mileniall Media
* AdMob
* InMobi(它给出了无效的适配器错误,但这是一个已知问题,而不是主要问题)

我已经下载并包含了 AdWhirl SDK 3.0.0、相应网络的 jar,并执行了手册中包含的所有步骤(清单文件中的更改,包括 lib 等)

我已将 AdWhirl 代码放入我的应用程序中。

作为 AdWhirlLayout 占位符的布局。

<LinearLayout
        android:id="@+id/ads"
        android:layout_width="fill_parent"
        android:layout_height="52dip"
        android:layout_weight="0"
        android:background="#0f0"/>

广告布局代码:

adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "ad whirl code");
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(UIUtils.dip(320), UIUtils.dip(52));
adWhirlLayout.setBackgroundColor(Color.DKGRAY);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
adLayout.invalidate();

我可以看到两种布局都显示了(由于它们具有的颜色)。

我也知道网络连接正确,因为我可以在 logcat 中看到

05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Showing ad:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     nid: d10c4fe5e08f469ca1992bfe277902f5
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     name: millennial
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     type: 6
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     key: XXXXX
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     key2: 
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Valid adapter, calling handle()

在网络站点上 - 我在那里看到了广告请求。

但无论如何,布局都是灰色的。我很困惑。

4

1 回答 1

1

The documentation for AdWhirl is pretty horrible. Try this much simpler way to inflate the AdWhirl layout:

Instead of creating the layout through code you can simply create it through your normal XML layout file. Don't use the LinearLayout like their instructions suggest (I think it's outdated). Instead just place this element in your layout wherever you want the banner to be:

    <com.adwhirl.AdWhirlLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />

Seriously, that's it. Be sure your AdWhirl key is in the Manifest as well (either within the <activity> or <application> tag):

    <meta-data android:value="Your Key"
         android:name="ADWHIRL_KEY"/>

If you really need to do anything programmatically you can give the layout an id as usual and use findViewById. Lemme know if this helps.

于 2011-07-18T04:11:35.760 回答