Tôi muốn thực hiện các chức năng tùy chỉnh để tải hình ảnh từ ImageView
như app:imageUrl="@{status.imageUrl}"
này trong mã dưới đây:Làm cách nào để tạo liên kết dữ liệu tùy chỉnh trong Android? (Android studio)
<?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>
<variable
name="status"
type="com.databinding.data.Status" />
</data>
<RelativeLayout
android:id="@+id/status_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/status_avatar"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:contentDescription="@null"
app:imageUrl="@{status.imageUrl}"/>
</RelativeLayout>
</layout>
Làm thế nào để viết chức năng này có thể tải hình ảnh tự động từ một @{status.imageUrl}
? Sử dụng thư viện này com.android.databinding
.