코틀린
코틀린 EditText 글자 입력 체크 ( TextWatcher )
아스키의 공부방
2022. 7. 31. 16:11
728x90
반응형
etv_email_signUp.addTextChangedListener (object: TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
if (p0 != null && p0.isNotEmpty()) {
Log.d("로그", "beforeTextChanged p0 : $p0")
Log.d("로그", "beforeTextChanged p0 last : ${p0.last()}")
}
}
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
if (p0 != null && p0.isNotEmpty()) {
Log.d("로그", "onTextChanged p0 : $p0")
Log.d("로그", "onTextChanged p0 last : ${p0.last()}")
}
}
override fun afterTextChanged(p0: Editable?) {
if (p0 != null && p0.isNotEmpty()) {
Log.d("로그", "afterTextChanged p0 : $p0")
Log.d("로그", "afterTextChanged p0 last : ${p0.last()}")
}
}
})
asd를 입력하면
아래와 같은 순서로 나타난다.
onTextChanged >> afterTextChanged >> beforeTextChanged
728x90
반응형