From 38e60194af80262c2c674ed45b12ef840fca4bcc Mon Sep 17 00:00:00 2001 From: Ssamssamukja <109636635+Ssamssamukja@users.noreply.github.com> Date: Tue, 14 May 2024 18:09:05 +0900 Subject: [PATCH] =?UTF-8?q?[nunu/#23]=20feat:=205=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EA=B5=AC=ED=98=842?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 메모 앱 구현 - mainActivity에서 Search Fragment 대신 Memo Activity 보여주기 --- .../java/com/example/umc_6th/MainActivity.kt | 6 +++ .../java/com/example/umc_6th/MemoActivity.kt | 45 +++++++++++++++++++ .../app/src/main/res/layout/activity_memo.xml | 27 +++++++++++ .../main/res/layout/activity_memo_confirm.xml | 15 +++++++ 4 files changed, 93 insertions(+) create mode 100644 UMC_6th/app/src/main/java/com/example/umc_6th/MemoActivity.kt create mode 100644 UMC_6th/app/src/main/res/layout/activity_memo.xml create mode 100644 UMC_6th/app/src/main/res/layout/activity_memo_confirm.xml diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt index da47a74..d0592be 100644 --- a/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt +++ b/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt @@ -87,10 +87,16 @@ class MainActivity : AppCompatActivity() { true } R.id.fragment_search -> { + // MemoActivity 시작 + val intent = Intent(this, MemoActivity::class.java) + startActivity(intent) + true + /* search fragment supportFragmentManager.beginTransaction().replace( R.id.main_container, SearchFragment() ).commit() + */ true } R.id.fragment_locker -> { diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/MemoActivity.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/MemoActivity.kt new file mode 100644 index 0000000..fa38cf2 --- /dev/null +++ b/UMC_6th/app/src/main/java/com/example/umc_6th/MemoActivity.kt @@ -0,0 +1,45 @@ +package com.example.umc_6th +import android.app.AlertDialog +import android.os.Bundle +import android.widget.EditText +import androidx.appcompat.app.AppCompatActivity + + +class MemoActivity : AppCompatActivity() { + private var editTextNote: EditText? = null + private var savedNoteContent = "" + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_memo) + editTextNote = findViewById(R.id.editTextMemo) + } + + override fun onResume() { + super.onResume() + if (!savedNoteContent.isEmpty()) { + editTextNote!!.setText(savedNoteContent) + } + } + + override fun onPause() { + super.onPause() + savedNoteContent = editTextNote!!.text.toString() // 현재 EditText 내용 저장 + } + + override fun onRestart() { + super.onRestart() + AlertDialog.Builder(this) // 다이얼로그 생성 + .setTitle("재작성 확인") + .setMessage("메모를 새로 작성하시겠습니까?") + .setPositiveButton("예") { dialog, which -> + editTextNote!!.setText("") + } + .setNegativeButton( + "아니오" + ) { dialog, which -> + } + .show() + } +} + diff --git a/UMC_6th/app/src/main/res/layout/activity_memo.xml b/UMC_6th/app/src/main/res/layout/activity_memo.xml new file mode 100644 index 0000000..8e9c86c --- /dev/null +++ b/UMC_6th/app/src/main/res/layout/activity_memo.xml @@ -0,0 +1,27 @@ + + + + + +