Closed P1NG2WIN closed 3 years ago
Works with default viewBinding api
private var _viewBinding: DialogGabiBinding? = null
private val viewBinding get() = _viewBinding!!
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
_viewBinding = DialogGabiBinding.inflate(LayoutInflater.from(context))
isCancelable = canBeCanceled
val dialog = AlertDialog.Builder(requireContext())
.setView(viewBinding.root)
.setCancelable(canBeCanceled)
.create()
//initDialogView()
return dialog
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
initDialogView()
return viewBinding.root
}
override fun onDestroyView() {
super.onDestroyView()
_viewBinding = null
}
Try to use dialogViewBinding
instead of viewBinding
Try to use
dialogViewBinding
instead ofviewBinding
Did not help. Anyway, i just removed AlertDialog from DialogFragment
I've got crush
Can't access the Fragment View's LifecycleOwner when getView() is null i.e., before onCreateView() or after onDestroyView()
when set view to dialog (setView(viewBinding.root)
)supportFragmentManager?.let { updateDialog.showDialog(it) } //showDialog
Dialog
BaseDialogFragment