【发布时间】:2020-11-07 18:08:00
【问题描述】:
我决定将 admob 广告添加到我的项目中,但在创建 onCreate 方法时出现错误 - 未解决的参考:setContentView。尽管我按照 Google Admob 文档中的方式进行了所有操作 求助,我是Android Studio的大佬enter image description here
【问题讨论】:
标签: android-studio kotlin
我决定将 admob 广告添加到我的项目中,但在创建 onCreate 方法时出现错误 - 未解决的参考:setContentView。尽管我按照 Google Admob 文档中的方式进行了所有操作 求助,我是Android Studio的大佬enter image description here
【问题讨论】:
标签: android-studio kotlin
在 AdMob 文档中,它针对 Activity 显示。
请查看setContentView详情
在您的 FRAGMENT 案例中,将“setContentView(R.layout.activity_main)”替换为以下任何内容
如果正在使用数据绑定,那么
FragmentHomeBinding.inflate(inflater, container, false)
否则,
inflater.inflate(R.layout.fragment_home, container, false)
请查看Adding a user interface了解更多详情
【讨论】: