android-jetpack - 如何在 Compose 中创建 DialogFragment?
问题描述
我正在将我的应用程序转换为 Compose,
class BinDetailDialogFragment //private View pic;
: DialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return ComposeView(requireContext()).apply {
setContent {
Text(
text = "This is Recipe Fragment",
style = TextStyle(
fontSize = TextUnit.Sp(21)
)
)
}
}
}
}
当我打开对话框片段时:
activity?.supportFragmentManager?.let {
BinDetailDialogFragment.newInstance().show(it, BinDetailDialogFragment.TAG)
}
它抛出
java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)V in class Landroidx/compose/ui/platform/ComposeView; or its super classes (declaration of 'androidx.compose.ui.platform.ComposeView' appears in
解决方案
推荐阅读
- javascript - JavaScript 引擎和事件循环有什么区别?
- python - 如何将拆分字符串应用于熊猫中的整个excel数据集
- angular - 使用 preflight 拦截 HTTP 请求,然后执行原始请求
- python - 如何使用 Python 发送设备孪生的动态报告属性
- linux - 使用 chmem -d 离线内存恢复如何停止?
- angular - 我可以使用异步管道将 observable 解包到视图变量而不是使用 ngIf 吗?
- javascript - Canvas 实现颜色系统后无法绘制部分图像
- azure-active-directory - 如果我使用 Azure AD,是否可以创建一个用户组,并且在该组内,不同的用户可以访问不同的资源?
- c# - WCF '故障 System.ServiceModel.Channels.MsmqInputChannel'
- c - 关于scanf的返回值