我只是想让广告随着我的feed的内容移动--在我看来,当你的feed增加1的时候,你的广告不会随之调整它们的位置,这在我看来是没有意义的:
myMoPubAdapter = new MoPubRecyclerAdapter(this, myInnerAdapter);
myMoPubAdapter.setContentChangeStrategy(MoPubRecyclerAdapter.ContentChangeStrategy.MOVE_ALL_ADS_WITH_CONTENT);
// Create an ad renderer and view binder that describe your native ad layout.
ViewBinder myViewBinder = new ViewBinder.Builder(R.layout.my_ad_layout)
.titleId(R.id.my_ad_title)
.textId(R.id.my_ad_text)
.mainImageId(R.id.my_ad_image)
.iconImageId(R.id.my_ad_icon)
.callToActionId(R.id.my_call_to_action)
.privacyInformationIconImageId(R.id.native_ad_privacy_information_icon_image)
.build();
MoPubStaticNativeAdRenderer myRenderer = new MoPubStaticNativeAdRenderer(myViewBinder);
myMoPubAdapter.registerAdRenderer(myRenderer);
rv.setAdapter(myMoPubAdapter);我只想让广告动起来。例如:假设当应用程序第一次启动时,广告位于位置2,随后,我在feed顶部插入了一篇帖子,我希望广告位于位置3。这是合乎逻辑的。
如果我将这一行添加到代码中:
`myMoPubAdapter.setContentChangeStrategy(MoPubRecyclerAdapter.ContentChangeStrategy.MOVE_ALL_ADS_WITH_CONTENT);`我的提要中没有显示任何内容-以前在我的提要中显示的没有这行的广告现在消失了。
如果我去掉这一行,广告将再次显示,但广告保持其位置,因此如果我在位置2中添加了一个插件,并在提要的顶部插入了一个新帖子,则广告仍将位于位置2。
我以为ContentChangeStrategy的设置会允许广告随着内容移动--为什么它现在能像预期的那样工作?
发布于 2016-03-24 07:01:58
mopub文档声明:
如果希望MoPub在插入或删除项目时保持其广告的绝对位置不变,只需从适配器调用notifyDataSetChanged(),而不是notifyItemsInserted或notifyItemsRemoved。
在您的数据集发生更改后,您将调用什么?
https://stackoverflow.com/questions/36173250
复制相似问题