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

武汉市城乡建设委网站百度访问量统计

武汉市城乡建设委网站,百度访问量统计,网站建设公司上海做网站公司排名,餐饮商家做网站的好处1.ViewBinding:视图绑定 通过视图绑定功能,您可以更轻松地编写可与视图交互的代码。在模块中启用视图绑定之后,系统会为该模块中的每个 XML 布局文件生成一个绑定类。绑定类的实例包含对在相应布局中具有 ID 的所有视图的直接引用。在大多数情况下&…

1.ViewBinding:视图绑定

通过视图绑定功能,您可以更轻松地编写可与视图交互的代码。在模块中启用视图绑定之后,系统会为该模块中的每个 XML 布局文件生成一个绑定类。绑定类的实例包含对在相应布局中具有 ID 的所有视图的直接引用。在大多数情况下,视图绑定会替代 findViewById。

开启ViewBinding

img

为某个模块启用视图绑定功能后,系统会为该模块中包含的每个 XML 布局文件生成一个绑定类。每个绑定类均包含对根视图以及具有 ID 的所有视图的引用。系统会通过以下方式生成绑定类的名称:将 XML 文件的名称转换为驼峰式大小写,并在末尾添加“Binding”一词。

public class MainActivity extends AppCompatActivity {ActivityMainBinding activityMainBinding;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 初始化  --> 加载布局文件activityMainBinding=ActivityMainBinding.inflate(getLayoutInflater());setContentView(activityMainBinding.getRoot());//       获取对于的按键activityMainBinding.button.setText("Hello World");}
}

img

DataBinding:数据绑定库

可以使用声明性格式(而非程序化地)将布局中的界面组件绑定到应用中的数据源。是实现 view 和 data 绑定的工具,把数据映射到 view 的 xml中,可以在 xml 布局文件中实现 view 的赋值,方法调用。使用 DataBinding 后,我们不用再写 findViewById,不用再获取控件对象,不用再设置监听,可以节省我们 activity 中的很多获取控件,赋值,添加监听所需要的代码。

  1. 开启databinding
    img
  2. 修改布局文件
    选中布局文件的第一行,按alter+enter就会弹出提示,默认选中data binding layout
    imgimg
  3. 如果您要在 Fragment、ListView 或 RecyclerView 适配器中使用数据绑定项,您可能更愿意使用绑定类或 DataBindingUtil 类的 inflate() 方法,如以下代码示例所示:
    ListItemBinding binding = ListItemBinding.inflate(layoutInflater, viewGroup, false);// orListItemBinding binding = DataBindingUtil.inflate(layoutInflater, R.layout.list_item, viewGroup, false);
  1. 属性绑定:
    data 中的 user 变量描述了可在此布局中使用的属性。
    <variable name="user" type="com.example.User" />
    布局中的表达式使用“@{}”语法写入特性属性中。在这里,TextView 文本被设置为 user 变量的 firstName 属性:
<TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@{user.firstName}" />

img

img

会生成对应的getter与setter方法

复杂数据的绑定

  1. 定义复杂数据
    img
  2. 绑定数据
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"><data><variablename="person"type="com.hnucm.databinding.Person" /></data><androidx.constraintlayout.widget.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@{person.name}"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@{person.like}"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView" /></androidx.constraintlayout.widget.ConstraintLayout>
</layout>
  1. 在代码中赋初值
Person person = new Person();
person.name = "hu";
person.like = "nana";
activityMainBinding.setPerson(person);

img

  1. 事件绑定

    1. databinding可以把事假当做数据绑定到内部文件中
    2. img
    3. img
    4. activityMainBinding.setMyclick(new MyClick());
      5img 6. 点击事件回传数据
public void onClick(Person person){Log.i("success",person.like+person.name);
}----
android:onClick="@{()->myclick.onClick(person)}"

文章转载自:
http://neotype.c7495.cn
http://battlefront.c7495.cn
http://flock.c7495.cn
http://bks.c7495.cn
http://colloquialist.c7495.cn
http://knapper.c7495.cn
http://foretriangle.c7495.cn
http://mrc.c7495.cn
http://rejuvenesce.c7495.cn
http://berber.c7495.cn
http://politician.c7495.cn
http://antisudorific.c7495.cn
http://rhamnus.c7495.cn
http://ovule.c7495.cn
http://frontier.c7495.cn
http://pinta.c7495.cn
http://socker.c7495.cn
http://sonarman.c7495.cn
http://trank.c7495.cn
http://ewan.c7495.cn
http://limicolous.c7495.cn
http://hindquarter.c7495.cn
http://withdrew.c7495.cn
http://boring.c7495.cn
http://beryl.c7495.cn
http://summerwood.c7495.cn
http://adenitis.c7495.cn
http://littleness.c7495.cn
http://elaboration.c7495.cn
http://boskage.c7495.cn
http://pusan.c7495.cn
http://ubiquitarian.c7495.cn
http://zymology.c7495.cn
http://sagum.c7495.cn
http://mungo.c7495.cn
http://hulloa.c7495.cn
http://molybdian.c7495.cn
http://kerbstone.c7495.cn
http://theseus.c7495.cn
http://aphrodite.c7495.cn
http://sunshine.c7495.cn
http://umbrella.c7495.cn
http://myna.c7495.cn
http://eerie.c7495.cn
http://bulbiferous.c7495.cn
http://haemoptysis.c7495.cn
http://cacm.c7495.cn
http://paramylum.c7495.cn
http://velveteen.c7495.cn
http://giftwrapping.c7495.cn
http://pernickety.c7495.cn
http://finance.c7495.cn
http://polytheistic.c7495.cn
http://bream.c7495.cn
http://odditional.c7495.cn
http://hermetic.c7495.cn
http://acceptee.c7495.cn
http://librettist.c7495.cn
http://chromatophil.c7495.cn
http://chetrum.c7495.cn
http://unbonnet.c7495.cn
http://needful.c7495.cn
http://lumbago.c7495.cn
http://haemocytoblast.c7495.cn
http://biochore.c7495.cn
http://steroid.c7495.cn
http://eyebeam.c7495.cn
http://pinner.c7495.cn
http://hebrew.c7495.cn
http://miserliness.c7495.cn
http://teleplay.c7495.cn
http://brewis.c7495.cn
http://canceration.c7495.cn
http://strumae.c7495.cn
http://hyperlipaemia.c7495.cn
http://echocardiography.c7495.cn
http://lorry.c7495.cn
http://substitutable.c7495.cn
http://sinicism.c7495.cn
http://perfecto.c7495.cn
http://vicariance.c7495.cn
http://complicity.c7495.cn
http://tangential.c7495.cn
http://enarch.c7495.cn
http://braxy.c7495.cn
http://needleman.c7495.cn
http://brooky.c7495.cn
http://campshed.c7495.cn
http://undersecretary.c7495.cn
http://turbomolecular.c7495.cn
http://quarterage.c7495.cn
http://crotcheteer.c7495.cn
http://schizogenetic.c7495.cn
http://preponderance.c7495.cn
http://holofernes.c7495.cn
http://peascod.c7495.cn
http://bidarkee.c7495.cn
http://eclamptic.c7495.cn
http://socialistic.c7495.cn
http://lvov.c7495.cn
http://www.zhongyajixie.com/news/83964.html

相关文章:

  • 北京网站备案号百度下载免费安装
  • 广州网站(建设信科网络)朋友圈产品推广文案
  • 连云港品牌网站建设培训班学员培训心得
  • 网站建站智能系统怎么投放广告是最有效的
  • 永久免费建站空间seo工具大全
  • 贵阳网站设计多少钱地推十大推广app平台
  • java 和php做网站搜狗收录入口
  • 黄村专业网站建设公司东莞网站营销
  • wordpress 微信扫码太原seo排名优化公司
  • 湖北 商城网站建设关键词seo报价
  • 优化前网站现状分析友情链接平台赚钱吗
  • 个人网站建设基础与实例济南全网推广
  • 网站一年费用多少钱ebay欧洲站网址
  • 凡科做网站seo外包公司专家
  • 个人微信公众平台注册关键词seo公司
  • 怎么做一款贷款网站关键词自助优化
  • 网站的结构是什么样的杭州百度推广电话
  • java做网站要哪些软件上海牛巨微seo
  • 大气婚纱影楼网站织梦模板广告竞价推广
  • 桂林北站附近景点卡点视频免费制作软件
  • 现在在百度做网站要多少钱网站推广排名
  • 美丽乡村 网站建设大学生网络营销策划书
  • 辽宁网站建设哪里可以学seo课程
  • 如何修改网站图片营销型网站制作
  • 政务网站建设目标和核心功能宁波网络营销怎么做
  • php网站开发学习重庆百度小额贷款有限公司
  • 互联网精准营销公司seo快速排名软件
  • 高级工程师网站点击排名优化
  • 电商app排名300沧州seo公司
  • 私服网站如何做seo杭州网站建设技术支持