Closed epkjoja closed 3 years ago
Hi @epkjoja,
Could you check that called super.onCreateView(inflater, container, savedInstanceState)
on your onCreateView
method?
And the binding
property should not be accessed onCreateView()
or after onDestroyView()
, because it aligns with the fragment's lifecycle.
My DialogFrament's doesn't override onCreateView
at all. They override onCreateDialog
instead. See the documentation for onCreateDialog here: https://developer.android.com/reference/androidx/fragment/app/DialogFragment#onCreateDialog(android.os.Bundle)
As the documentation states, onCreateDialog will be called just before onCreateView and you don't have to override onCreateView at all. So it's clear that I can't use your library as it is today because it won't allow usage before onCreateView.
I don't know if it's at all possible to support this use case with your library? It might be so that such a use case isn't supported by data binding?
Hi, @epkjoja
Could you check using the 1.0.9-SNAPSHOT
?
On your DialogFragment, you should call super.onCreateDialog
before using the binding
property.
Thanks!
Hi @skydoves,
No, it's still the same error with the new version. _binding
is still uninitialized when I try to fetch it from my onCreateDialog
.
Hi, sorry for the late reply.
I think if you are using the BindableDialogFragment
for implementing just an AlertDialog, I do not recommend using the way.
The purpose of the Bindable___
is to inflate the basic databinding property for communicating view models.
So every view inflation should be done in the onCreateView
and the binding
property must be used in the onViewCreated
.
If you need to handle both ways, inflating the custom view for the AlertDialog must be handled independently regardless of the BindableDialogFragment
's process.
Is your feature request related to a problem?
I started to use your library in my project and it works really great, except for one thing. My DialogFragments are using
onCreateDialog
and an AlertDialogBuilder to inflate the layout. When trying to use thebinding
at that point it will result in an IllegalStateException with message "...binding cannot be accessed before onCreateView() or after onDestroyView()". Would it be possible to make your BindingDialogFragment to also support this use case in some way?