android MVVM开发框架——(1)DataBinding 基础应用
附上mvvm中databinding的基本应用链接,只有找到了基本用法才能继续进阶
1,listview布局
<?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">
<data>
<!--引用自定义的适配器listviewadapter-->
<import type="com.lh.mvvm.adapter.ListViewAdapter" />
<variable
name="adapter"
type="ListViewAdapter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--将适配器绑定到listview-->
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:adapter="@{adapter}" />
</LinearLayout>
</layout>
注意,这里面有个自定义的adapter,这里先把布局写出来,adapter后面再写
2,item布局
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<!--这里沿用双向绑定的userbean-->
<import type