Comments (7)
我举个例子,看是否和我理解的一致
<data>
<variable
name="account"
type="com.hi.dhl.demo.binding.Account" />
</data>
初始化 DataBinding 的时候,同时给 account 赋值? 我的理解正确吗?
from binding.
是的,我加了一下,这样传个block进去,便于直接setVariable
inline fun Fragment.databind(noinline block: (ViewDataBinding.() -> Unit)? = null) = FragmentBindingDelegate(this, block)
private val binding by databind {
setVariable(BR.m, playVM)
}
from binding.
是的,我加了一下,这样传个block进去,便于直接setVariable
inline fun Fragment.databind(noinline block: (ViewDataBinding.() -> Unit)? = null) = FragmentBindingDelegate(this, block)
private val binding by databind {
setVariable(BR.m, playVM)
}
嗯嗯,如果我的理解是对的话,是可以加上的, 你的这样写法思路是对的,但是有点麻烦,我会在后续的版本加上这个
from binding.
但是有个问题咨询一下,你是在什么场景下会用到?
from binding.
正常场景下都会用到吧,如果不这样写的话,初始化和参数赋值就放在两个地方,而我更喜欢在一个地方把binding的配置弄好,这样在其他地方可以直接使用
from binding.
我错了,再不需要显示使用databinding的时候,懒加载这种写法会导致参数无法配置上去,而这种情况是比较多的,还是需要手动的去配置
from binding.
complete v1.0.4 close #3
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
- Fatal Exception: java.lang.IllegalStateException: onGetLayoutInflater() cannot be executed until the Fragment is attached to the FragmentManager. HOT 13
- 更新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.