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

๐Ÿ’ป Extracurricular/์ฝ”๋ฎค๋‹ˆํ‹ฐ ๋ชจ๊ฐ์ฝ”

๋ชจ๊ฐ์ฝ” < Kotlin ๊ธฐ์ดˆํŽธ > - 13์ผ์ฐจ

โœ… ์˜ค๋Š˜์˜ ๋ฌธ์ œ : 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์ผ์ฐจ

 

๐ŸŒˆ ๋ชจ๊ฐ์ฝ” <์ฝ”ํ‹€๋ฆฐ ๊ธฐ์ดˆํŽธ> - 13์ผ์ฐจ by guswlsdl04 | ์ฝ”๋“œ๋ฉ”์ดํŠธ

โœ… ์˜ค๋Š˜์˜ ๋ฌธ์ œ : Activity ์ „ํ™˜ํ•˜๊ธฐ โšก ๋น„๋ฐ€๋ฒˆํ˜ธ ์ฒดํฌ ํ›„ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ๋‹ค๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ์–ด์š”. ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”. ๋ผ๋Š” ๋ฌธ๊ตฌ ํ‘œ์‹œ โšก ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๋งž๋‹ค๋ฉด MemoActivity ๋กœ ์ „ํ™˜ (์ „ํ™˜ ์‹œ MainActivi

codemate.kr