在碎片Android中实现广告横幅
我已经设法实现了本教程中解释的锚定自适应横幅(锚定自适应横幅)。 首先在活动中,然后在片段中。
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentTestBinding.inflate(inflater, container, false)
context ?: return binding.root
setupAdview(binding)
setHasOptionsMenu(true)
return binding.root
}
然后,我在片段类中有以下内容:
override fun onPause() {
adView.pause()
super.onPause()
}
override fun onResume() {
super.onResume()
adView.resume()
}
override fun onDestroy() {
adView.destroy()
super.onDestroy()
}
我正在使用导航组件的单个活动。当我启动应用程序时,广告显示出色。当我转到另一个片段并返回时,广告不再显示了。
I have managed to implement the anchored adaptive banner as explained in this tutorial (anchored adaptive banner).
First within an Activity and then within a Fragment.
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentTestBinding.inflate(inflater, container, false)
context ?: return binding.root
setupAdview(binding)
setHasOptionsMenu(true)
return binding.root
}
Then I have the following in my fragment class:
override fun onPause() {
adView.pause()
super.onPause()
}
override fun onResume() {
super.onResume()
adView.resume()
}
override fun onDestroy() {
adView.destroy()
super.onDestroy()
}
I am using single activity with navigation component. When I start the app, the ads are showing great. When I then move to another fragment and return back, the ads aren't showing anymore.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论