데이터 결합 라이브러리 | Android 개발자 | Android Developers
Build.gradle에 다음과 같이 추가해준다.
buildFeatures {
dataBinding = true
}
<layout>
으로 감싸주어야 한다.<?xml version="1.0" encoding="utf-8"?>
<layout <!--LayOut으로 감싸주어야한다. !-->
xmlns:app="<http://schemas.android.com/apk/res-auto>"
xmlns:tools="<http://schemas.android.com/tools>">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="<http://schemas.android.com/apk/res/android>"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="259dp"
android:layout_height="280dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</FrameLayout>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="클릭하시오"
app:layout_constraintBottom_toTopOf="@+id/frameLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
DtaBindingUtil.setContentView(activity, layoutId)
로 binding 된 객체를 얻어올 수 있다.