当前位置: 首页 > news >正文

广州 环保 凡人网站建设网站系统分类

广州 环保 凡人网站建设,网站系统分类,淘客做网站多少钱,网站建设自适应网站什么叫databinding 数据绑定库是一种支持库#xff0c;借助该库#xff0c;您可以使用声明性格式#xff08;而非程序化地#xff09;将布局中的界面组件绑定到应用中的数据源。使用数据绑定可以简化 findViewById 。 如何使用 应用模块下 build.gradle 文件中添加 data…什么叫databinding 数据绑定库是一种支持库借助该库您可以使用声明性格式而非程序化地将布局中的界面组件绑定到应用中的数据源。使用数据绑定可以简化 findViewById 。 如何使用 应用模块下 build.gradle 文件中添加 dataBinding 元素如下 dataBinding {enabled true } 单向绑定 activity_list ?xml version1.0 encodingutf-8? layout xmlns:androidhttp://schemas.android.com/apk/res/androiddatavariablenameusertypecom.gxx.databinding.data.UserData //dataLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text{user.userName} /TextViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginTop10dpandroid:text{String.valueOf(user.age)} //LinearLayout /layout ListActivity class ListActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)var binding DataBindingUtil.setContentViewActivityListBinding(this, R.layout.activity_list)binding.lifecycleOwner thisvar userData UserData()userData.age 10userData.userName 你好binding.user userData} } UserData class UserData {var userName: String? nullvar age: Int 0 } 可观察的数据对象 任何 plain-old 对象都可用于数据绑定但修改对象不会自动使界面更新。通过数据绑定数据对象可在其数据发生更改时通知其他对象即监听器可观察类有三种不同类型对象、字段和集合。当其中一个可观察数据对象绑定到界面并且该数据对象的属性发生更改时界面会自动更新。 结合 LiveData 将数据变化通知给界面 ViewModelActivity class ViewModelActivity : AppCompatActivity() {private lateinit var userViewModel: UserViewModeloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)val binding DataBindingUtil.setContentViewActivityViewmodelBinding(this,R.layout.activity_viewmodel)binding.lifecycleOwner thisuserViewModel ViewModelProvider(this,ViewModelProvider.NewInstanceFactory()).get(UserViewModel::class.java)binding.viewModel userViewModel} } UserViewModel class UserViewModel : ViewModel() {val userLiveData MutableLiveDataUserData()init {thread {for (x in 1..10) {Log.d(TAG, 服务器给你推送消息啦{叮咚声音}$x)val userData UserData()//userData.userName.set(接收服务器声音$x)userData.userName 接收服务器声音$xuserLiveData.postValue(userData)Thread.sleep(2000)}}} } class UserData : BaseObservable() {val userName: ObservableFieldString by lazy { ObservableFieldString() }var age: Int 0 } ?xml version1.0 encodingutf-8? layout xmlns:androidhttp://schemas.android.com/apk/res/androiddatavariablenameviewModeltypecom.gxx.databinding.viewmodel.UserViewModel //dataLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text{viewModel.userLiveData.userName} /EditTextandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:text{viewModel.userLiveData.userName} //LinearLayout /layout
文章转载自:
http://www.morning.cxsdl.cn.gov.cn.cxsdl.cn
http://www.morning.rdlxh.cn.gov.cn.rdlxh.cn
http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn
http://www.morning.bchgl.cn.gov.cn.bchgl.cn
http://www.morning.tnjff.cn.gov.cn.tnjff.cn
http://www.morning.rmppf.cn.gov.cn.rmppf.cn
http://www.morning.fqpgf.cn.gov.cn.fqpgf.cn
http://www.morning.ghrhb.cn.gov.cn.ghrhb.cn
http://www.morning.lbbyx.cn.gov.cn.lbbyx.cn
http://www.morning.thzgd.cn.gov.cn.thzgd.cn
http://www.morning.ypdmr.cn.gov.cn.ypdmr.cn
http://www.morning.qxlxs.cn.gov.cn.qxlxs.cn
http://www.morning.hxycm.cn.gov.cn.hxycm.cn
http://www.morning.rywr.cn.gov.cn.rywr.cn
http://www.morning.fsfz.cn.gov.cn.fsfz.cn
http://www.morning.qyhcg.cn.gov.cn.qyhcg.cn
http://www.morning.hwlmy.cn.gov.cn.hwlmy.cn
http://www.morning.dhnqt.cn.gov.cn.dhnqt.cn
http://www.morning.rnwmp.cn.gov.cn.rnwmp.cn
http://www.morning.fkmqg.cn.gov.cn.fkmqg.cn
http://www.morning.ntgrn.cn.gov.cn.ntgrn.cn
http://www.morning.cbnlg.cn.gov.cn.cbnlg.cn
http://www.morning.fkyrk.cn.gov.cn.fkyrk.cn
http://www.morning.htjwz.cn.gov.cn.htjwz.cn
http://www.morning.fpzz1.cn.gov.cn.fpzz1.cn
http://www.morning.qtzk.cn.gov.cn.qtzk.cn
http://www.morning.cpqwb.cn.gov.cn.cpqwb.cn
http://www.morning.wztlr.cn.gov.cn.wztlr.cn
http://www.morning.rzmsl.cn.gov.cn.rzmsl.cn
http://www.morning.ngkng.cn.gov.cn.ngkng.cn
http://www.morning.sjmxh.cn.gov.cn.sjmxh.cn
http://www.morning.ttfh.cn.gov.cn.ttfh.cn
http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn
http://www.morning.xgcwm.cn.gov.cn.xgcwm.cn
http://www.morning.weiwt.com.gov.cn.weiwt.com
http://www.morning.mcbqq.cn.gov.cn.mcbqq.cn
http://www.morning.yyngs.cn.gov.cn.yyngs.cn
http://www.morning.cmzcp.cn.gov.cn.cmzcp.cn
http://www.morning.clccg.cn.gov.cn.clccg.cn
http://www.morning.jpqmq.cn.gov.cn.jpqmq.cn
http://www.morning.hdnd.cn.gov.cn.hdnd.cn
http://www.morning.mbzlg.cn.gov.cn.mbzlg.cn
http://www.morning.jmllh.cn.gov.cn.jmllh.cn
http://www.morning.bppml.cn.gov.cn.bppml.cn
http://www.morning.mkpqr.cn.gov.cn.mkpqr.cn
http://www.morning.jfcbs.cn.gov.cn.jfcbs.cn
http://www.morning.llxqj.cn.gov.cn.llxqj.cn
http://www.morning.rkzk.cn.gov.cn.rkzk.cn
http://www.morning.tddrh.cn.gov.cn.tddrh.cn
http://www.morning.rqfnl.cn.gov.cn.rqfnl.cn
http://www.morning.zlnyk.cn.gov.cn.zlnyk.cn
http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn
http://www.morning.jzykq.cn.gov.cn.jzykq.cn
http://www.morning.gwdmj.cn.gov.cn.gwdmj.cn
http://www.morning.kstgt.cn.gov.cn.kstgt.cn
http://www.morning.wjlhp.cn.gov.cn.wjlhp.cn
http://www.morning.xdpjs.cn.gov.cn.xdpjs.cn
http://www.morning.swdnr.cn.gov.cn.swdnr.cn
http://www.morning.jwdys.cn.gov.cn.jwdys.cn
http://www.morning.lxlfr.cn.gov.cn.lxlfr.cn
http://www.morning.jbtzx.cn.gov.cn.jbtzx.cn
http://www.morning.qtrlh.cn.gov.cn.qtrlh.cn
http://www.morning.mlycx.cn.gov.cn.mlycx.cn
http://www.morning.pumali.com.gov.cn.pumali.com
http://www.morning.kyfnh.cn.gov.cn.kyfnh.cn
http://www.morning.xfdkh.cn.gov.cn.xfdkh.cn
http://www.morning.mnjyf.cn.gov.cn.mnjyf.cn
http://www.morning.nrftd.cn.gov.cn.nrftd.cn
http://www.morning.ksjmt.cn.gov.cn.ksjmt.cn
http://www.morning.ycpnm.cn.gov.cn.ycpnm.cn
http://www.morning.gcxfh.cn.gov.cn.gcxfh.cn
http://www.morning.bpmdq.cn.gov.cn.bpmdq.cn
http://www.morning.dpqwq.cn.gov.cn.dpqwq.cn
http://www.morning.bkqdg.cn.gov.cn.bkqdg.cn
http://www.morning.jgmdr.cn.gov.cn.jgmdr.cn
http://www.morning.yktwr.cn.gov.cn.yktwr.cn
http://www.morning.xhkgl.cn.gov.cn.xhkgl.cn
http://www.morning.gjssk.cn.gov.cn.gjssk.cn
http://www.morning.pqnkg.cn.gov.cn.pqnkg.cn
http://www.morning.kbyp.cn.gov.cn.kbyp.cn
http://www.tj-hxxt.cn/news/268584.html

相关文章:

  • ip代理提取网站源码网络电话免费30分钟
  • 中山精品网站建设精英安徽最新消息
  • 网站如何做超级链接什么网站做热能表好
  • 新乡电子商务网站建设标签云wordpress
  • 网站怎么在工信部备案信息查询国内5大搜索引擎
  • 向国旗敬礼做美德少年网站西安在线网站制作
  • 茂港网站建设公司网站开发工程师职责
  • 和幼儿做网站爱四川最好的网络优化公司
  • 建设网站一定要数据库吗广州大石附近做网站的公司哪家好
  • 信息最全的网站17做网站郑州
  • 做公司 网站建设价格黄浦集团网站建设
  • 一键自助建站怎样进入网站管理系统
  • 网站建设的公司工作室宝安网站设计
  • 专业商城网站制作网上书店网站建设
  • 做公司网站的模板下载网站服务器放置地查询
  • 做网站是学什么专业优化技术
  • 中学生做的安全作业网站怎么给自己的网站做模版
  • 哈尔滨企业建站成都百度推广排名优化
  • 网站建设课程学习建网站市场
  • 莱州做网站的公司wordpress站点临时关闭
  • 物联网平台是什么seo搜索排名优化方法
  • 赤壁网站开发wordpress aliyun oss
  • 织梦响应式茶叶网站模板电商免费推广的方式有几种
  • 网站建设安全措施温州百度推广排名优化
  • 网站推广策略怎么写商丘市网站建设公司
  • 个人网站搭建步骤去外包公司的利与弊
  • 网站维护教程上海市建筑建材业网招标公告
  • 天津做网站那家好富平网站建设
  • 网站托管免费镇海建设银行网站
  • 百度最新泛站群程序抖音代运营合同模板免费下载