kbyyah
2022.03.27
@kbyyah님이 새 포스트를 작성했습니다.
전환
package com.example.secretmemo import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.EditText class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) findViewById<Button>(R.id.button).setOnClickListener{ val editEmail = findViewById<EditText>(R.id.Email) val editPassword = findViewById<EditText>(R.id.Password) val emailText = editEmail.text.toString() val passwordText = editPassword.text.toString() val intent = Intent(this, MemoActivity::class.java) if (passwordText == "12345678") { startActivity(intent) this.finish() } else { System.out.println("비밀번호가 틀렸어요. 다시 입력해주세요.") } } } }
kbyyah
2022.03.27
@kbyyah님이 새 포스트를 작성했습니다.
메모 레이아웃
<?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=".MemoActivity"> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/floatingActionButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="167dp" android:clickable="true" android:focusable="true" android:contentDescription="@+string/button" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" tools:srcCompat="@tools:sample/avatars"
kbyyah
2022.03.26
@kbyyah님이 새 포스트를 작성했습니다.
11일차
<?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"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" android:text="이메일" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/email" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="16dp" android:layout_marginEnd="16dp" android:ems="10" android:inputType="textEmailAddress" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" android:text="비밀번호" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/email" /> <EditText android:id="@+id/editTextNumberPassword3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="16dp" android:layout_marginEnd="24dp" android:ems="10" android:inputType="numberPassword" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView2" /> <Button android:id="@+id/button2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="24dp" android:layout_marginEnd="24dp" android:text="확인" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/editTextNumberPassword3" /> </androidx.constraintlayout.widget.ConstraintLayout> package com.example.myapplication import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import android.widget.Button import android.widget.EditText class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) findViewById<Button>(R.id.button2).setOnClickListener{ val editPassword = findViewById<EditText>(R.id.editTextNumberPassword3) val password = editPassword.text.toString() val editEmail = findViewById<EditText>(R.id.email) val email = editEmail.text.toString() if (email =="11@naver.com"){ if (password =="12345678"){ Log.d("11","통과") } else Log.d("11","비밀번호를 다시 입력하세요.") } else { Log.d("11","이메일을 다시 입력하세요.") } } } }
kbyyah
2022.03.21
@kbyyah님이 새 포스트를 작성했습니다.
10일차
<?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"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="비밀번호를 입력해주세요." app:layout_constraintBottom_toTopOf="@+id/editTextNumberPassword" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> <EditText android:id="@+id/editTextNumberPassword" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="9dp" android:layout_marginTop="73dp" android:layout_marginEnd="9dp" android:ems="10" android:inputType="numberPassword" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="28dp" android:layout_marginTop="20dp" android:text="Button" app:layout_constraintStart_toStartOf="@+id/textView" app:layout_constraintTop_toBottomOf="@+id/editTextNumberPassword" /> </androidx.constraintlayout.widget.ConstraintLayout>
kbyyah
2022.03.17
@kbyyah님이 새 포스트를 작성했습니다.
8일차 과제
package com.example.myapplication import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import com.google.android.material.floatingactionbutton.FloatingActionButton import android.content.res.ColorStateList import android.graphics.Color import android.widget.Button import kotlin.random.Random class MainActivity : AppCompatActivity() { private val numbers = arrayListOf<Int>() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val num1 = findViewById<Button>(R.id.buttonNum1) val num2 = findViewById<Button>(R.id.buttonNum2) val num3 = findViewById<Button>(R.id.buttonNum3) val num4 = findViewById<Button>(R.id.buttonNum4) val num5 = findViewById<Button>(R.id.buttonNum5) val num6 = findViewById<Button>(R.id.buttonNum6) findViewById<FloatingActionButton>(R.id.floatingActionButton2).setOnClickListener { numbers.clear() setLottoNum(num1) setLottoNum(num2) setLottoNum(num3) setLottoNum(num4) setLottoNum(num5) setLottoNum(num6) } } private fun setLottoNum(lottoNum: Button) { var num = 0 val numbers = arrayListOf<Int>() while (true) { num = Random.nextInt(45) + 1 if (!numbers.contains(num)) { numbers.add(num) break } } lottoNum.text = "${num}" if (num <= 10) { lottoNum.backgroundTintList = ColorStateList.valueOf(Color.rgb(255, 255, 0)) } else if (num <= 20) { lottoNum.backgroundTintList = ColorStateList.valueOf(Color.rgb(0, 255, 255)) } else if (num <= 30) { lottoNum.backgroundTintList = ColorStateList.valueOf(Color.rgb(255, 0, 255)) } else if (num <= 40) { lottoNum.backgroundTintList = ColorStateList.valueOf(Color.rgb(0, 0, 225)) } else { lottoNum.backgroundTintList = ColorStateList.valueOf(Color.rgb(255, 0, 0)) } } } 추첨앱
kbyyah
2022.03.16
@kbyyah님이 새 포스트를 작성했습니다.
7일차 과제
과제 package com.example.myapplication import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log import com.google.android.material.floatingactionbutton.FloatingActionButton import android.content.res.ColorStateList import android.graphics.Color import android.widget.Button import kotlin.random.Random class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val num1 = findViewById<Button>(R.id.buttonNum1) val num2 = findViewById<Button>(R.id.buttonNum2) val num3 = findViewById<Button>(R.id.buttonNum3) val num4 = findViewById<Button>(R.id.buttonNum4) val num5 = findViewById<Button>(R.id.buttonNum5) val num6 = findViewById<Button>(R.id.buttonNum6) findViewById<FloatingActionButton>(R.id.floatingActionButton2).setOnClickListener{ num1.text="01" num1.backgroundTintList=ColorStateList.valueOf(Color.rgb(138,118,155)) num1.setTextColor(Color.BLACK) num2.text="03" num2.backgroundTintList=ColorStateList.valueOf(Color.rgb(138, 215, 245 )) num2.setTextColor(Color.BLACK) num3.text="09" num3.backgroundTintList=ColorStateList.valueOf(Color.rgb(255, 215, 238)) num3.setTextColor(Color.BLACK) num4.text="21" num4.backgroundTintList=ColorStateList.valueOf(Color.rgb(215, 228, 228)) num4.setTextColor(Color.BLACK) num5.text="39" num5.backgroundTintList=ColorStateList.valueOf(Color.rgb(295,0, 138)) num5.setTextColor(Color.BLACK) num6.text="17" num6.backgroundTintList=ColorStateList.valueOf(Color.rgb(215, 118, 100 )) num6.setTextColor(Color.BLACK) } } }
kbyyah
2022.03.15
@kbyyah님이 새 포스트를 작성했습니다.
6일차
<?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"> <TextView android:id="@+id/textView" android:layout_width="73dp" android:layout_height="14dp" android:layout_marginEnd="50dp" android:layout_marginBottom="50dp" android:textAppearance="@style/TextAppearance.AppCompat.Body1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.443" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.252" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/floatingActionButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="16dp" android:layout_marginBottom="32dp" android:clickable="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:srcCompat="@android:drawable/checkbox_on_background" /> <EditText android:id="@+id/sky" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" android:text="sky" tools:layout_editor_absoluteX="100dp" tools:layout_editor_absoluteY="573dp" /> <LinearLayout android:layout_width="321dp" android:layout_height="476dp" android:backgroundTint="#DDB642" android:gravity="center" android:orientation="vertical" app:layout_constraintBottom_toTopOf="@+id/sky" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.622" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView" app:layout_constraintVertical_bias="0.0"> <Button android:id="@+id/buttonNum1" android:layout_width="70dp" android:layout_height="80dp" app:cornerRadius="80dp" /> <Button android:id="@+id/buttonNum6" android:layout_width="70dp" android:layout_height="80dp" android:backgroundTint="#8F3113" android:gravity="center" app:cornerRadius="80dp" /> <Button android:id="@+id/buttonNum5" android:layout_width="70dp" android:layout_height="80dp" android:backgroundTint="#6B913F" android:gravity="center" app:cornerRadius="80dp" /> <Button android:id="@+id/buttonNum4" android:layout_width="70dp" android:layout_height="80dp" android:backgroundTint="#C6B948" android:gravity="center" app:cornerRadius="80dp" /> <Button android:id="@+id/buttonNum3" android:layout_width="70dp" android:layout_height="80dp" android:backgroundTint="#3377AE" android:gravity="center" app:cornerRadius="80dp" /> <Button android:id="@+id/buttonNum2" android:layout_width="70dp" android:layout_height="80dp" android:backgroundTint="#EF7E7E" android:gravity="center" app:cornerRadius="80dp" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> button