Android Jetpack

Room Advanced - 1 (XML)

----___<<<<< 2023. 2. 2. 07:18

Room + ListAdapter + ViewModel 등을 함께 이용해서 CRUD 앱을 만들어보겠습니다.

 

아래와 같은 앱을 만들어보겠습니다.

 

random number를 생성하여 업데이트 삭제를 할 수 있는 앱입니다.

 

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/create"
android:layout_margin="10dp"
android:text="create random number"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/numberRV"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:gravity="center"
android:text="id"
android:textSize="15sp"/>
<TextView
android:id="@+id/randomNum"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:gravity="center"
android:text="randomNum"
android:textSize="15sp"/>
<Button
android:id="@+id/update"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:text="update"/>
<Button
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:text="delete"/>
</LinearLayout>
view raw number_item.xml hosted with ❤ by GitHub