소개
게시글
질문&답변
2021.08.01
토스트 메세지가 순차적으로 뜨지않습니다.
제시해주신 방법대로 다 해봤지만 여전히 마지막 토스트 메세지만 뜨는군요.. ); 혹시나해서 다른 기기로 실행해서 테스트해보니까 그 기기에서는 순차적으로 잘 뜹니다. 코드 문제는 아니고 제 휴대폰 문제인 것 같습니다. 프로젝트를 진행하는데 있어서 크게 중요한 문제는 아니라서 그냥 넘어가도 될 것 같습니다. 문제가 된다면 다른 기기로 바꿔서 진행하면 될 것 같습니다. (; 답변 감사합니다. :)
- 0
- 6
- 520
질문&답변
2021.07.31
토스트 메세지가 순차적으로 뜨지않습니다.
1. 테스트 한 영상 주소입니다. (죄송합니다. 질문 게시판의 동영상 첨부 방법을 몰라서 블로그에 영상게시했습니다. 동영상 첨부 방법을 알아보고 다음부터는 질문 게시판 기능으로 첨부해서 올리겠습니다.) https://blog.naver.com/jgee0116/222452134389 2. MainActivity 모든 소스코드입니다. package com.gorani.mysampleapp import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.databinding.DataBindingUtil import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.ktx.auth import com.google.firebase.ktx.Firebase import com.gorani.mysampleapp.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { private lateinit var auth : FirebaseAuth private lateinit var binding : ActivityMainBinding // 데이터바인딩 override fun onCreate (savedInstanceState: Bundle?) { auth = Firebase. auth super .onCreate(savedInstanceState) setContentView(R.layout. activity_main ) Toast.makeText( this, auth . currentUser ?. uid . toString () , Toast. LENGTH_SHORT ).show() binding = DataBindingUtil.setContentView( this, R.layout. activity_main ) // 데이터바인딩 // 회원가입 버튼 val joinBtnClicked = findViewById (R.id. joinBtn ) joinBtnClicked.setOnClickListener { // EditText 에서 입력한 값을 가져오는 방법 // 첫 번째 방법 : findViewById 로 직접 가져오기 // val email = findViewById (R.id.emailArea) // val password = findViewById (R.id.pwdArea) // 두 번째 방법 : databinding 으로 가져오기 (MVVM 패턴에서 사용하는 방식 ) val email = binding . emailArea val password = binding . pwdArea auth .createUserWithEmailAndPassword(email. text .toString() , password. text .toString()) .addOnCompleteListener( this ) { task -> if (task. isSuccessful ) { // Sign in success, update UI with the signed-in user's information Toast.makeText( this, "Join Success" , Toast. LENGTH_SHORT ).show() } else { // If sign in fails, display a message to the user. Toast.makeText( this, "Join Failed" , Toast. LENGTH_SHORT ).show() } } } // 로그아웃 버튼 val logoutBtn = binding . logoutBtn logoutBtn.setOnClickListener { auth .signOut() Toast.makeText( this, auth . currentUser ?. uid . toString () , Toast. LENGTH_SHORT ).show() } // 로그인 버튼 binding . loginBtn .setOnClickListener { val email = binding . emailArea val password = binding . pwdArea auth .signInWithEmailAndPassword( email. text .toString() , password. text .toString() ) .addOnCompleteListener( this ) { task -> if (task. isSuccessful ) { // Sign in success, update UI with the signed-in user's information Toast.makeText( this, "Login Success" , Toast. LENGTH_SHORT ).show() Toast.makeText( this, auth . currentUser ?. uid . toString () , Toast. LENGTH_LONG ).show() val intent = Intent( this, BoardListActivity:: class . java ) startActivity(intent) } else { // If sign in fails, display a message to the user. Toast.makeText( this, "Login Failed" , Toast. LENGTH_SHORT ).show() } } } } }
- 0
- 6
- 520