本文介绍了如何以编程方式创建admob标语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用代码创建admob智能横幅?我的布局完全是用代码构建的。
How can i create an admob smart banner with code? my layout is completely build with code.
推荐答案
您可以像这样或多或少地做到这一点:
You can do it more or less like this:
LinearLayout adContainer = <container>;
AdView adView = new AdView(activity)
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(<your-publisher-id>);
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adView.loadAd(adRequest);
// Place the ad view.
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
adContainer.addView(adView, params);
干杯
这篇关于如何以编程方式创建admob标语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!