데이터 바인딩 – 앱 만들어
화면에 일부 데이터가 표시되고 사용자는 “좋아요”를 클릭하여 카운터를 늘리고 진행 상황을 업데이트할 수 있습니다. 1. 데이터 바인딩 레이아웃으로 변환을 선택합니다. 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> <variable name=”viewmodel” type=”com.example.databinding.viewmodel.MyViewModel” /> </data> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width=”match_parent” android:layout_height=”match_parent” tools:context=”.MainActivity”> <ImageView android:id=”@+id/imageView” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginBottom=”40dp” android:minWidth=”50dp” android:minHeight=”50dp” app:layout_constraintBottom_toTopOf=”@id/progressBar” app:layout_constraintStart_toStartOf=”@id/progressBar” app:popularityIcon=”@{viewmodel.popularity}” /> <TextView … Read more