Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActivityViewBinding 是否应该主动在onCreate时调用setContentView #28

Open
xiaozhikang0916 opened this issue Jun 7, 2021 · 1 comment

Comments

@xiaozhikang0916
Copy link

ActivityViewBinding 里是在委托首次赋值时调用的setContentView,根据使用习惯的不同,会使得调用时机不明确:例如可能在数据请求返回之后才遇到首次操作UI的时机,那么在此之前委托的属性都没被获取、不会调用setContentView,使得页面一直显示空白。

对于类似的情况,是不是应该监听Activity的生命周期,主动在 ON_CREATE 事件里调用setContentView

@hi-dhl
Copy link
Owner

hi-dhl commented Jun 23, 2021

不哈意思,最近信息有点多,刚看见这条信息

嗯嗯,是的,现在确实是在首次赋值时调用的setContentView,我当时也考虑过类似的问题,是否需要做生命周期的检查,后来思考了一下,在实际项目中应该很少会有情况,大部分情况都在 ON_CREATE 中做一些 View 的初始化,权衡了一下就没有加了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants