使用 kotlin 在 android 中与底部工作表进行数据绑定

Bla*_*Guy 2 data-binding android mvvm kotlin

如何在 kotlin 中使用带有底部工作表对话框的数据绑定。我在使用带有底部工作表对话框的数据绑定时遇到问题

Bla*_*Guy 6

我通过将底部工作表转换为数据绑定解决了这个问题,如下所示:

Bottom_sheet_pick_loc.xml

<layout >
.....
</layout >
Run Code Online (Sandbox Code Playgroud)

在活动或片段中:

val bottomSheet = BottomSheetDialog(this@MainActivity)
    val bindingSheet = DataBindingUtil.inflate<BottomSheetPickLocBinding>(
        layoutInflater,
        R.layout.bottom_sheet_pick_loc,
        null,
        false
    )
    bottomSheet.setContentView(bindingSheet.root)
Run Code Online (Sandbox Code Playgroud)