问题
I have a strange problem with integrating AdWhirl into my android app.
Networks connected through AdWhirl:
* Mileniall Media
* AdMob
* InMobi (it gives invalid adapter error but thats a known issue and not the main problem)
I've downoaded and included AdWhirl SDK 3.0.0, the jars for respective network and did all the steps included in the manual (changes in manifest file, lib including etc)
And I've put the AdWhirl code into my app.
Layout that is the placeholder for AdWhirlLayout.
<LinearLayout
android:id="@+id/ads"
android:layout_width="fill_parent"
android:layout_height="52dip"
android:layout_weight="0"
android:background="#0f0"/>
Code for ads layout:
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();
I can see that both of the layouts are shown (due to the color that they have).
I also know that the networks are connected correctly because I can see that in 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()
and on the network sites - I see the ad request there.
But the layout stays gray, no matter what. I'm puzzled.
回答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.
来源:https://stackoverflow.com/questions/5964869/empty-adwhirl-layout-on-android-no-ads-shown