-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 메모 앱 구현 - mainActivity에서 Search Fragment 대신 Memo Activity 보여주기
- Loading branch information
1 parent
50c76bd
commit 38e6019
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
UMC_6th/app/src/main/java/com/example/umc_6th/MemoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<EditText>(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() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/white"> | ||
|
||
<EditText | ||
android:id="@+id/editTextMemo" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:hint="메모를 입력하세요" | ||
app:layout_constraintBottom_toTopOf="@+id/btnMemoConfirm" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/btnMemoConfirm" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="확인" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:padding="16dp" | ||
android:background="@color/white"> | ||
|
||
<TextView | ||
android:id="@+id/textViewNote" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="메모 내용" | ||
android:textSize="18sp"/> | ||
|
||
</LinearLayout> |