I'm trying to make a BottomSheetDialog inside my MainActivity, but right now I'm using synthetic to bind my views. But now I'm stuck with how to attach ViewBinding
to my BottomSheetDialog
.
Here's what I do, using synthetic.
dialog = BottomSheetDialog(this, R.style.BottomDialogStyle)
dialogView = LayoutInflater.from(this).inflate(R.layout.test_dialog, dialog.mainContainer, false)
dialog.setContentView(dialogView)
And here is what's confusing me with ViewBinding
dialog = BottomSheetDialog(this, R.style.BottomDialogStyle)
binding = TestDialogBinding.inflate(?)
dialog.setContentView(binding.root)
From my example above, I'm wondering what I should fill the parameters with, because unlike in an activity where I could just fill that parameter with layoutInflater
or in a RecyclerView
Adapter where I cant fill that parameter with
LayoutInflater.from(parent.context), parent, and false
.
You also can create a LayouInflater :
val inflater = LayoutInflater.from(requireContext())
then pass inflater to :
binding = TestDialogBinding.inflate(inflater)