โ ์ค๋์ ๋ฌธ์ : Activity ์ ํํ๊ธฐ
โก ๋น๋ฐ๋ฒํธ ์ฒดํฌ ํ ๋น๋ฐ๋ฒํธ๊ฐ ํ๋ ธ๋ค๋ฉด
๋น๋ฐ๋ฒํธ๊ฐ ํ๋ ธ์ด์. ๋ค์ ์ ๋ ฅํด์ฃผ์ธ์. ๋ผ๋ ๋ฌธ๊ตฌ ํ์
โก ๋น๋ฐ๋ฒํธ๊ฐ ๋ง๋ค๋ฉด MemoActivity ๋ก ์ ํ
(์ ํ ์ MainActivity๋ ์คํ์์ ์ ๊ฑฐ)
๐ MainActivity.kt
package com.comu.android.secretmemo
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import android.content.Intent
import android.widget. TextView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val intent = Intent(this, MemoActivity::class.java)
val textMsg = findViewById<TextView>(R.id.textView)
findViewById<Button>(R.id.button).setOnClickListener{
// EditText ์ปดํฌ๋ํธ๋ฅผ ์ฐพ์์ editText ๋ณ์์ ์ ์ฅํ๋ค.
val editEmail = findViewById<EditText>(R.id.editTextEmail)
val emailText = editEmail.text.toString()
// editText ์์ ์ฌ์ฉ์๊ฐ ์
๋ ฅํ ํ
์คํธ๋ฅผ ๋ถ๋ฌ์ passwordText ์ ์ ์ฅํ๋ค.
val editText=findViewById<EditText>(R.id.editTextNumberPassword2)
val pwText=editText.text.toString()
if(emailText == "guswlsdl04@naver.com"){
if(pwText == "123456"){
Log.d("SecretMemo", "ํต๊ณผ")
startActivity(intent)
this.finish()
}
else{
Log.d("SecretMemo","๋น๋ฐ๋ฒํธ ์ค๋ฅ")
textMsg.text = "๋น๋ฐ๋ฒํธ๊ฐ ํ๋ ธ์ด์. ๋ค์ ์
๋ ฅํด์ฃผ์ธ์."
}
}
else {
Log.d("SecretMemo", "์ด๋ฉ์ผ ์ค๋ฅ")
textMsg.text = "์ด๋ฉ์ผ์ด ํ๋ ธ์ด์. ๋ค์ ์
๋ ฅํด์ฃผ์ธ์."
}
}
}
}
๐ AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comu.android.secretmemo" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SecretMemo" >
<activity
android:name=".MemoActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".MainActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
๐ ์คํ๊ฒฐ๊ณผ
์ด๋ฉ์ผ๊ณผ ๋น๋ฐ๋ฒํธ๊ฐ ์๋ ๊ฒ์ด ๋ ๋์ ๊ฑฐ ๊ฐ์์
์ด๋ฉ์ผ์ ์์ ์ง ์๊ณ ์งํํ์ต๋๋ค!
https://codemate.kr/@guswlsdl04/๋ชจ๊ฐ์ฝ-์ฝํ๋ฆฐ-๊ธฐ์ดํธ-13์ผ์ฐจ
'๐ป Extracurricular > ์ฝ๋ฎค๋ํฐ ๋ชจ๊ฐ์ฝ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 15์ผ์ฐจ (0) | 2022.03.14 |
---|---|
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 14์ผ์ฐจ (0) | 2022.03.14 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 12์ผ์ฐจ (0) | 2022.03.14 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 11์ผ์ฐจ (0) | 2022.03.09 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 10์ผ์ฐจ (0) | 2022.03.09 |