android - 与 Youtube Player for Publishers 不兼容的片段类型
问题描述
我尝试在我们的 androidx 应用程序中添加最后一个 Youtube Player for Publishers v2.1.2。要添加这个播放器,我们必须创建一个新的YoutubeEmbedFragment extends Fragment
.
这里的问题是这个片段扩展android.app.Fragment
并且在我们的应用程序中我们使用androidx.appcompat.app.AppCompatActivity
,androidx.fragment.app
所以当我想添加这个 Youtube 播放器片段时:
getChildFragmentManager()
.beginTransaction()
.replace(R.id.player_container, youTubeEmbedFragment)
.commit();
它不会编译,因为
第二个参数类型错误。找到:'com.google.android.youtube.player.YouTubeEmbedFragment',需要:'androidx.fragment.app.Fragment'
我们如何在使用支持片段的同时也使用库?
解决方案
推荐阅读
- qlikview - 十亿行表增量负载,在 qlik 上进行硬删除
- python - 如何:Pandas 按 A、B 分组并将 A 组与 B 组的每一行绘制在一个图中
- c# - 为什么这个表达式在 C# 中无效?
- asp.net-core - 如何将标头中的证书传递给 OpenId Provider
- c# - Reactive Extensions - 切换,但等到前一个 observable 完成而不是取消
- php - 在哪里/如何在地理搜索即时搜索 js 中传递纬度经度
- go - 使用 kubeconfig 进行 helm 客户端安装 panding
- ssis - SSIS:DT_DECIMAL 可以接受空值吗?
- cv2 - 使用 cv2.omnidir.calibrate 校准鱼眼图像时的断言
- jquery - 使用 jQuery 从字符串中获取特定数据