小编Jos*_*ian的帖子

如何在 BottomSheetDialog 上使用视图绑定

我正在尝试在 MainActivity 中创建一个 BottomSheetDialog,但现在我正在使用合成来绑定我的视图。但现在我被如何附加ViewBinding到我的BottomSheetDialog.

这就是我所做的,使用合成材料。

dialog = BottomSheetDialog(this, R.style.BottomDialogStyle)
dialogView = LayoutInflater.from(this).inflate(R.layout.test_dialog, dialog.mainContainer, false)
dialog.setContentView(dialogView)
Run Code Online (Sandbox Code Playgroud)

这就是让我困惑的地方ViewBinding

dialog = BottomSheetDialog(this, R.style.BottomDialogStyle)
binding = TestDialogBinding.inflate(?)
dialog.setContentView(binding.root)
Run Code Online (Sandbox Code Playgroud)

从上面的示例中,我想知道应该用什么填充参数,因为与在活动中我可以只用layoutInflater或在RecyclerView 适配器中填充该参数不同,而在适配器中我不能用

LayoutInflater.from(parent.context), parent, and false

android kotlin android-viewbinding android-bottomsheetdialog

10
推荐指数
1
解决办法
7698
查看次数