728x90
반응형
findView..
Toast
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val btn : Button = findViewById(R.id.button)
val tv : TextView = findViewById(R.id.textView)
val etv : EditText = findViewById(R.id.editText)
etv.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
tv.text = etv.text
if (etv.text.length >= 6)
btn.visibility = View.VISIBLE
else
btn.visibility = View.INVISIBLE
}
override fun afterTextChanged(s: Editable?) {
}
})
btn.setOnClickListener {
Toast.makeText(this, tv.text, Toast.LENGTH_SHORT).show()
}
}
}
728x90
반응형
'코틀린' 카테고리의 다른 글
[코틀린] 데이터베이스 헬퍼 (0) | 2020.12.11 |
---|---|
[코틀린] 리사이클러뷰 (0) | 2020.12.11 |
[코틀린] 함수 | 단순화 | 익명 함수 (0) | 2020.12.10 |
[코틀린] 조건부 (0) | 2020.12.10 |
[코틀린] 변수 선언 | Null 안전 (0) | 2020.12.10 |