简体   繁体   English

Admob原生广告在recyclerview android公式中的定位

[英]Admob native ads positioning in recyclerview android formula

I was able to successfully populate items and admob native ads together into the recyclerview but the formula that I used that is (position % 4 == 0) for when to show the ads is not what the outcome I wanted it to be我能够成功地将项目和 admob 原生广告一起填充到回收站视图中,但是我使用的公式是(position % 4 == 0)何时显示广告并不是我想要的结果

It puts the native ad items at position 0 and after every 4 items.它将原生广告项目放置在位置 0 和每 4 个项目之后。

What I would like is to show the first two items, followed by an ad item and every after 4 items to show an ad item我想要的是显示前两个项目,然后是一个广告项目,然后每 4 个项目显示一个广告项目

Below is an image of what I want it to look like下面是我希望它看起来像的图像

ID

(position % 4) == offset ,在您的情况下 offset = 2 应该可以解决问题

also check that your position is not zero还要检查您的位置是否为零

if (position % 4 == 0 && position != 0) {
//Your Ads
..
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM