android studio 需要gradle 1.5.0以上才支持

 

dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}


另外在build.gradle module加入
dataBinding {
enabled true
}


这里 xml 的文件名叫 activity_basic.xml,那么生成的类就是 ActivityBasicBinding

参考:https://github.com/LyndonChin/MasteringAndroidDataBinding
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0603/2992.html
http://android.jobbole.com/82809/ mvpvm
http://www.android-studio.org/
https://halfthought.wordpress.com/2016/03/23/2-way-data-binding-on-android/ 双向绑定
需要android studio 2.1+
双向绑定例子
<EditText
    android:layout_marginLeft="10dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@={mapUser[`age_value`]}" />

 

单向绑定,没有“=”

android:text="@{mapUser[`age_value`]}"

 



相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-06-12
  • 2021-06-06
猜你喜欢
  • 2021-04-28
  • 2021-12-16
  • 2021-10-03
  • 2021-10-10
  • 2022-12-23
  • 2021-12-04
  • 2021-04-01
相关资源
相似解决方案