Closed cristan closed 3 years ago
class MyDialogFragment : DialogFragment() { private val binding: MyDialogBinding by dialogViewBinding(R.id.my_dialog_container) override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = AlertDialog.Builder(requireContext()) .setView(R.layout.my_dialog) .create() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { binding.myButton.setOnClickListener { dismiss() } } }
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_dialog_container" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button!" /> </FrameLayout>
I don't get a crash anymore (I did in 1.2.2), but doing anything with the binding (like setting the onClickListener to the Button) has no effect.
Will be fixed in 1.4.2
I don't get a crash anymore (I did in 1.2.2), but doing anything with the binding (like setting the onClickListener to the Button) has no effect.