android - 当我使用自定义布局而不是通货膨胀时,DialogFragment 什么也不显示
问题描述
我想用自定义 ui 创建 DialogFragment。使用自己制作的自定义布局对我来说很重要。但是当从 onCreateView DialogFragment 返回一个时,什么也没有显示。顺便说一句,当在简单片段的孩子中使用相同的代码时,视图按预期显示。
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val context = requireActivity()
contentLoaderView = createContentLoaderView(context)
return contentLoaderView
}
private fun createContentLoaderView(context: Context): ContentLoaderView{
return ContentLoaderView(context).apply{
attachContentView(R.layout.dialog_product_order)
attachViewModel(viewLifecycleOwner, viewModel)
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
}
当我使用充气机时,一切都很好。
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return LayoutInflater.from(context).inflate(R.layout.dialog_product_order, container, false)
}
我究竟做错了什么?
解决方案
推荐阅读
- php - 自动将 CSV 导入 MYSQL?
- java - 将 \t\n 显示为节点的原因是什么?
- python - 如何对 list.count() 的结果求和
- python - OverflowErro 无法将“int”放入索引大小的整数中
- django - 在 ElasticSearch/Django 中重建搜索索引时出错
- java - MyBatis 在一次查询中删除-插入-更新
- java - 如何在android中将字符串作为键盘输出发送?
- python - 矩阵乘法中的ValueError
- json - 如何获取多个 ARReferenceImages 名称以从 JSON 文件返回相同的数据?
- javascript - 内容安全策略与可变内联样式(CSP 与 CSS)