Hi everyone,
Sorry for the inconvenience. We haven't had a chance to update all of
our documentation fully yet. 4.1.0 made some changes to the way that
XML layouts work. In particular, you shouldn't need attrs.xml anymore.
Try the following and let me know if it works (or more importantly if
it doesn't):
1) Remove attrs.xml (or if you need it for your own custom attributes,
remove the parts related to AdViews).
2) Change the namespace in your layout from xmlns:ads="http://
schemas.android.com/apk/res/com.your.packagename"
to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
Also, in the simplest of cases, where your code simply does
AdView.loadAd(new AdRequest()), there's a new XML attribute to make
your code even simpler. Adding ads:loadAdOnCreate="true" should call
loadAd(new AdRequest()) for you when the ad is inflated from the XML.
This means that the simplest of cases just got simpler because it
requires no code at all (no finding the view from the layout just to
call loadAd with a blank ad request). Obviously keep in mind though
that using this method means you have less control over your ads like
when requests occur, and what goes in them.
We think this will be easier in the long run since you won't have to
create the attrs.xml file. Again, sorry for the inconvenience and
thanks for your patience.
Thanks,
-Tim
本文介绍了如何通过更新XML布局文件来简化广告加载的过程。主要步骤包括移除attrs.xml文件中与AdViews相关的部分,修改布局文件中的命名空间,并使用新的XML属性ads:loadAdOnCreate来自动加载广告。

1万+

被折叠的 条评论
为什么被折叠?



