Comments (7)
Normally we use DialogFragment like using a normal fragment. We create view in onCreateView and use views in onViewCreated (or onCreateView).
When use Fragment.viewBinding with viewBindingRootId . It will throw exception in Utils L46. Seems view hasn't added into dialog window. I checked androidx DialogFragment source code. It add view to dialog in onActivityCreated which after onCreateView and onViewCreated.
Now I am using viewBinding function without given rootViewId seems working.
After reading some source code, seems without given rootViewId, The lib will binding view from Fragment::requireView but with given rootViewId it will try to find view from dialog window. Internal logics in these two methods are different.
from viewbindingpropertydelegate.
Yeah, 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 in onActivityCreated
of DialogFragment
.
from viewbindingpropertydelegate.
DialogFragment
can be used as usual Fragment that will be added as View in layout or can be shown as Dialog. A ViewBinding
require a View. I will think how it can be done better. Right now DialogFragment
implementation isn't good a don't work everywhere. Let's discuss how to do that better
from viewbindingpropertydelegate.
Hi. I need to see code of the Fragment where you have the issue
from viewbindingpropertydelegate.
And stacktrace when crash occured
from viewbindingpropertydelegate.
Is there any reason why the author is finding the view in dialog view
, not fragment view
? Have the same issue
from viewbindingpropertydelegate.
@kirich1409 Maybe this way is better:
val view = dialog?.findViewById<View>(viewBindingRootId)
if (view != null) {
return view
}
return requireView().requireViewByIdCompat(viewBindingRootId)
Find the view from the dialog at first, then find it from the fragment view.
from viewbindingpropertydelegate.
Related Issues (20)
- Can give a sample of how to use RecyclerView.ViewHolder? HOT 1
- IllegalStateException: Fragment's view can't be accessed. HOT 6
- IllegalStateException FragmentViewBindingProperty.getLifecycleOwner HOT 1
- UnresolvedReference HOT 2
- Crash on language change HOT 7
- Android Studio Dolphin | 2021.3.1 does not show layout preview HOT 2
- IllegalStateException: Fragment's view can't be accessed. Fragment isn't added. - when trying to restore fragment state HOT 1
- Kkk
- Custom views are crashing preview after updating Android Studio up to Dolphin HOT 1
- Hgf
- Version 1.5.8 onwards causes error in RecyclerView HOT 1
- NoClassDefFoundError HOT 1
- Clear happens after onViewCreated HOT 3
- Generic type cannot be used HOT 5
- how to use 'noreflection:1.5.6' in this case? HOT 3
- Random crash when navigating between fragments back and forth. HOT 3
- Is it possible to provide support for viewBinding(ViewBinding::inflate) HOT 2
- java.lang.IllegalStateException: Fragment's view can't be accessed HOT 1
- Fatal Exception: java.lang.IllegalStateException: Host view isn't ready. LifecycleViewBindingProperty.isViewInitialized return false HOT 1
- How to correctly use a generic? View blank and onViewCreated() not called in Fragment nor Base HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viewbindingpropertydelegate.