Crash in DialogFragment. ID does not reference a View inside this View
See original GitHub issueI am using this library 1.4.5 version.
With this function
public inline fun <F : Fragment, T : ViewBinding> Fragment.viewBinding( crossinline vbFactory: (View) -> T, @IdRes viewBindingRootId: Int )
And working in activity and fragment.
When using in DialogFragment.
The app crash when I try to use viewBinding instance in onViewCreated callback.
After some investigated, found the dialog contentView will be set in onActivityCreated which is called after onViewCreated.
But the delegate will get the view from dialog inside.
Is that a bug? Please give some suggestions, thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Why does my NavController cannot find an ID that I already ...
The Logcat says failed because the java file, ID does not reference a View inside this Activity. But I clearly typed the ID: ......
Read more >Interact programmatically with the Navigation component
When you navigate to a destination that takes the full view of the NavHost (such as a <fragment> destination), the previous destination has...
Read more >id does not reference a view inside this activity
resource reference: In Java: R.id.name In XML: @[package:]id/name syntax: Why does it say "ID does not reference a view inside this activity" Does...
Read more >Using DialogFragment | CodePath Android Cliffnotes
Use onCreateView when the entire view of the dialog is going to be defined via custom XML. Use onCreateDialog when you just need...
Read more >Android DialogFragment - DigitalOcean
No more IllegalStateExceptions and leaked window crashes. ... onCreateView - Here you can create a Dialog using a custom view defined.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
DialogFragment
can be used as usual Fragment that will be added as View in layout or can be shown as Dialog. AViewBinding
require a View. I will think how it can be done better. Right nowDialogFragment
implementation isn’t good a don’t work everywhere. Let’s discuss how to do that betterYeah, we got the same issue, as we are accessing bindings in
onViewCreated
. After some digging we find out the same reason -dialog window
view is without our view, as it is added inonActivityCreated
ofDialogFragment
.