๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ฑ/๐Ÿ“˜Project

[Kotlin] TodoList ์•ฑ ๋งŒ๋“ค๊ธฐ๏ผ‘

Android Studio์™€ Kotlin์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ์•„์‹œ๋Š” ๋ถ„์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ ์„ค๋ช…์ž…๋‹ˆ๋‹ค.

 

์šฐ์„  ๋ฉ”๋ชจ ์•ฑ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ ์•ฑ์„ ๋‹ด์„ ํด๋”๋ฅผ ๋งŒ๋“ค์–ด์คŒ.

 

Android Studio ์‹คํ–‰ ํ›„ New Project๋ฅผ ํด๋ฆญํ•˜๊ณ 

Phone and Tablet์˜ Empty Activity ํด๋ฆญ ํ›„ Next๋ฅผ ๋ˆ„๋ฅด๊ณ  Name์€ TodoList(์ž์œ )๋กœ ์ ์–ด์คŒ.

 

์ด์ œ ์—ฌ๊ธฐ์„œ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์€ Language์™€ Minimum SDK์ž„.

์šฐ๋ฆฌ๋Š” Kotlin์œผ๋กœ ๊ฐœ๋ฐœ์„ ํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— Kotlin์œผ๋กœ ์„ค์ •ํ•ด์ฃผ๊ณ  

Minimum SDK๋Š” ์ด ์•ฑ์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์ตœ์†Œ ์‚ฌ์–‘์ด๋ฉฐ API 26 : Android 8.0(Oreo)๋กœ ํ•ด์ฃผ๊ณ  Finish๋ฅผ ๋ˆŒ๋Ÿฌ์คŒ.

SDK๊ฐ€ ๋„ˆ๋ฌด ๋†’๋‹ค๋ฉด ์ตœ์‹  ์Šค๋งˆํŠธํฐ OS๊ฐ€ ์•„๋‹ ๊ฒฝ์šฐ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์ง€ ์•Š๊ณ , ๋„ˆ๋ฌด ๋‚ฎ์œผ๋ฉด ๊ตฌํ˜„์ด ํž˜๋“ค์–ด์ง.

 

์•ฑ์„ ๋งŒ๋“ค๊ธฐ์ „์— ์œ ์šฉํ•œ ์ž๋ฃŒ 2๊ฐœ๋ฅผ ๊ฐ€์ ธ์˜ด!

โ–ช๏ธManifest

https://readystory.tistory.com/187

 

[Android] Manifest ๊ฐœ๋… ์žก๊ธฐ

์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋กœ์ ํŠธ์—๋Š” ๋ฐ˜๋“œ์‹œ ํฌํ•จ๋˜์–ด์•ผ ํ•˜๋Š” ํŒŒ์ผ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฑด ๋ฐ”๋กœ AndroidManifest.xml ํŒŒ์ผ์ž…๋‹ˆ๋‹ค. Manifest ํŒŒ์ผ์€ ํ”„๋กœ์ ํŠธ์˜ Source Set์˜ ๋ฃจํŠธ(๋ณ„๋„์˜ ์„ค์ •์„ ํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด src/main)์— ์œ„

readystory.tistory.com

 

โ–ช๏ธGradle

https://curryyou.tistory.com/368

 

[์•ˆ๋“œ๋กœ์ด๋“œ] ๊ทธ๋ ˆ์ด๋“ค Gradle Scripts์— ๋Œ€ํ•œ ์ •๋ฆฌ

# Gradle Scripts๋ž€? ์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๋ฉด Gradle Scripts ๋ผ๋Š” ์˜์—ญ์— build.gradle, settings.gradle ๋“ฑ์˜ ํŒŒ์ผ์ด ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ง„๋‹ค. ์ด ํŒŒ์ผ๋“ค์„ ํ†ตํ•ด ์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋กœ์ ํŠธ์˜ ๋นŒ๋“œ ์ •๋ณด, ๋ผ์ด๋ธŒ

curryyou.tistory.com

 

์ด์ œ ๋ณธ๊ฒฉ์ ์œผ๋กœ ์•ฑ์„ ๋งŒ๋“ค์–ด๋ด„.

 

๋จผ์ € ๋ˆˆ์— ๋ณด์ด๋Š” UI ๊ตฌ์„ฑ๋ถ€ํ„ฐ ํ• ๊ฑฐ์ž„.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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"
    tools:context=".MainActivity">

    <LinearLayout
        android:id="@+id/main_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingHorizontal="10dp"
        android:paddingVertical="5dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="TodoList"
            android:textColor="@color/black"
            android:textSize="20dp"
            android:textStyle="bold"/>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/main_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingHorizontal="10dp"
        android:background="#EAEAEA"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/main_title">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="์ƒํƒœ"
            android:textColor="@color/black"
            android:textSize="17dp"
            android:textStyle="bold"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="ํ•  ์ผ"
            android:textColor="@color/black"
            android:textSize="17dp"
            android:gravity="center"
            android:textStyle="bold"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="๋“ฑ๋ก์ผ"
            android:textColor="@color/black"
            android:textSize="17dp"
            android:textStyle="bold"/>

    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/mai_list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingVertical="5dp"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/main_bar"
        app:layout_constraintBottom_toTopOf="@+id/main_write"/>

    <LinearLayout
        android:id="@+id/main_write"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingHorizontal="10dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <EditText
            android:id="@+id/mai_todo_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="ํ•  ์ผ์„ ์ถ”๊ฐ€ํ•ด๋ณด์„ธ์š”."
            android:textColor="@color/black"
            android:textSize="15dp"
            android:textStyle="normal"
            android:inputType="text"
            android:maxLines="1"
            android:background="@null"
            android:layout_gravity="center"/>

        <ImageView
            android:id="@+id/mai_add_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon_add"
            android:layout_gravity="center"/>

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
activity_main.xml

 

์•„์ด์ฝ˜์€ drawble์—์„œ New → Vector Asset์„ ํด๋ฆญํ•ด ์›ํ•˜๋Š” ์•„์ด์ฝ˜์„ ๋„ฃ์–ด์คŒ.

 

์ด์ œ ๋ฆฌ์ŠคํŠธ์— ๋“ค์–ด๊ฐˆ ๊ฐ๊ฐ์˜ ํ•ญ๋ชฉ์„ ๋งŒ๋“ค์–ด์ค„ ๊ฒƒ์ธ๋ฐ ์ด๋Š” RecyclerView๋ฅผ ์‚ฌ์šฉํ•  ๊ฑฐ์ž„.

 

โ–ช๏ธRecyclerView

https://velog.io/@appletorch/RecyclerView%EB%9E%80

 

RecyclerView๋ž€?

RecyclerView๋ž€? ์˜ค๋Š˜์€ ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ์ž์ฃผ์‚ฌ์šฉ๋˜๋Š” RecyclerView์— ๊ด€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ •์˜ ์•ˆ๋“œ๋กœ์ด๋“œ ๊ณต์‹๋ฌธ์„œ์—๋Š” A flexible view for providing a limited window into a large data set. ๋กœ ์†Œ

velog.io

 

๋ฆฌ์ŠคํŠธ์— ๋“ค์–ด๊ฐˆ ํ•ญ๋ชฉ์˜ UI๋ฅผ ๋งŒ๋“ค์–ด์คŒ.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingVertical="5dp">

    <CheckBox
        android:id="@+id/lis_state"
        android:layout_width="55dp"
        android:layout_height="match_parent"/>

    <TextView
        android:id="@+id/lis_todo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="ํ• ์ผ์ž…๋‹ˆ๋‹ค"
        android:textColor="@color/black"
        android:textSize="15dp"
        android:textStyle="bold"
        android:maxLines="1"
        android:paddingHorizontal="5dp"
        android:layout_gravity="center"/>

    <TextView
        android:id="@+id/lis_date"
        android:layout_width="65dp"
        android:layout_height="wrap_content"
        android:text="22.22.22"
        android:textColor="@color/black"
        android:textSize="15dp"
        android:gravity="center"
        android:layout_gravity="center"/>

</LinearLayout>
list_item.xml

 

To be Continued..