Comments (13)
收到,感谢反馈,我这里尝试复现一下
from binding.
请修改一下使用方式,不用在构造函数中传递 layoutId,使用如下方式
class FragmentNav1 : Fragment() {
// DataBinding
val binding: FragmentMainBinding by databind()
// ViewBinding
val binding: FragmentMainBinding by viewbind()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return binding.root
}
}
from binding.
请修改一下使用方式,不用在构造函数中传递 layoutId,使用如下方式
class FragmentNav1 : Fragment() { // DataBinding val binding: FragmentMainBinding by databind() // ViewBinding val binding: FragmentMainBinding by viewbind() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { return binding.root } }
试了一下,使用此方式bug依然存在,找了一下,发现这个链接:
https://blog.csdn.net/yechaoa/article/details/81017600
可能跟在Fragment中使用有关系,建议兼容一下
有更新,建议同步更新一下FragmentDelegate<T: ViewBinding> 实现
from binding.
@kakarrot 收到,感谢提供的方案,我研究一下,我会尽快更新版本
from binding.
请修改一下使用方式,不用在构造函数中传递 layoutId,使用如下方式
class FragmentNav1 : Fragment() { // DataBinding val binding: FragmentMainBinding by databind() // ViewBinding val binding: FragmentMainBinding by viewbind() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { return binding.root } }
试了一下,使用此方式bug依然存在,找了一下,发现这个链接:
https://blog.csdn.net/yechaoa/article/details/81017600
可能跟在Fragment中使用有关系,建议兼容一下
有更新,建议同步更新一下FragmentDelegate<T: ViewBinding> 实现
想请问一下你的 Fragment 的版本号是多少?我这边尝试了以上文章的两种方式,均可以正常运行,可否留一个微信,想咨询一下步骤
from binding.
androidx.fragment:fragment-ktx:1.3.1
嵌套的3层fragment,最里层的fragment被动态添加/显示/隐藏,bug不是必现的,自己手机没有发生过,目前看到的都是
Firebase统计上报过来的记录,也没有固定的手机型号和Android版本,应该是在特殊情况下才能复现。
from binding.
我也遇到了,最后发现是网络请求回调时,界面已经销毁了,但你还使用databing对象就会必现。
from binding.
我也遇到了,最后发现是网络请求回调时,界面已经销毁了,但你还使用databing对象就会必现。
页面销毁的时候, binding 实例也会跟着销毁
from binding.
fragment 在 onDestroyView() 里面如果调用 binding 停止动画,释放资源的时候,binding已经为空了,所以最好的binding置null 时机应该是 onDestoryView() 执行结束后,我使用的时候改成了下面的实现
com/hi/dhl/binding/base/FragmentDelegate.kt
from binding.
fragment 在 onDestroyView() 里面如果调用 binding 停止动画,释放资源的时候,binding已经为空了,所以最好的binding置null 时机应该是 onDestoryView() 执行结束后,我使用的时候改成了下面的实现
感谢反馈,你是对的,我看了一下,确实应该在 Fragment#onDestoryView 之后进行销毁。
from binding.
我也遇到了,最后发现是网络请求回调时,界面已经销毁了,但你还使用databing对象就会必现。
@hy-liuyuzhe 销毁之后,如果再次使用,由于 delegate property 会被再次初始化。 这应该也是 @kakarrot 反馈的这个问题#31 (comment) 的原因,我会尽快修复这个问题
from binding.
Fragment中如果在lifecycleScope.launchWithCatch的onFinally回调里使用bind对象并且此时界面销毁了,还是会报错 java.lang.IllegalStateException: onGetLayoutInflater() cannot be executed until the Fragment is attached to the FragmentManager. v1.1.9
from binding.
Fragment中如果在lifecycleScope.launchWithCatch的onFinally回调里使用bind对象并且此时界面销毁了,还是会报错 java.lang.IllegalStateException: onGetLayoutInflater() cannot be executed until the Fragment is attached to the FragmentManager. v1.1.9
你好,可否添加我的wechat : hi-dhl, 想详细咨询一下
from binding.
Related Issues (20)
- 在Navigation启动的Fragment中使用报错 HOT 1
- ActivityDataBinding里OS版本小于Q时为什么要添加一个空白的fragment? HOT 1
- 在BRAVH中怎么使用呢 HOT 1
- NoSuchMethodException问题 HOT 2
- 使用viewbind时,如何在使用xml布局的自定义ViewGroup中使用呢 HOT 4
- 版本时间写错啦,都2021年啦 HOT 5
- ActivityViewBinding 是否应该主动在onCreate时调用setContentView HOT 1
- 自定义View的混淆规则 HOT 2
- 遇到个bug HOT 9
- 更新kotlin后,出现一下问题 HOT 2
- 关于ViewGroupDataBinding的一个问题 HOT 6
- SmartRefreshLayout自定义RefreshHeader时,报java.lang.NoSuchMethodException的错误 HOT 13
- 1.1.6版本找不到databind了 HOT 3
- 同一类型的多个 fragment 实例的 binding.view 引用错位问题 HOT 2
- Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option HOT 1
- onGetLayoutInflater() cannot be executed until the Fragment is attached to the FragmentManager HOT 4
- 开启混淆会报错,按照文档添加了混淆规则
- 有一定的几率会报错闪退,Android 12 红米手机 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 binding.