마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

EditText에서 한 글자가 완성됐을 때, 첫 글자만 가져오고 두 번째 글자는 계속 편집상태로 유지하는 법 [closed]

0 추천
editText.doOnTextChanged { text, start, before, count ->
  Log.i("text: |$text|, start: $start, before: $before, count: $count")
  if (before == 1 && count == 2) {
    label.append("\n${text?.first()}")
    editText.text.delete(0, 1)
  }
}

두 번째 글자가 시작할 때 첫 번째 글자를 가져오고, 두 번째 글자의 편집상태는 유지되게 코드를 짰습니다. 

근데 분명 delete 한 글자가 되살아 납니다. 

천지인 키보드로 `김밥`을 입력하고 로그를 찍었습니다..  (|| 는 임의로 넣은 겁니다)

||, start: 0, before: 1, count: 0
|ㄱ|, start: 0, before: 0, count: 1
|기|, start: 0, before: 1, count: 1
|깅|, start: 0, before: 1, count: 1
|김|, start: 0, before: 1, count: 1
|김ㅂ|, start: 0, before: 1, count: 2
|ㅂ|, start: 0, before: 1, count: 0
|김비|, start: 0, before: 1, count: 2
|비|, start: 0, before: 1, count: 0
|김바|, start: 0, before: 1, count: 2
|바|, start: 0, before: 1, count: 0
|김밥|, start: 0, before: 1, count: 2
|밥|, start: 0, before: 1, count: 0

 

되살아난 `김` 때문에 TextView에는 이렇게만 찍히고 있습니다. 

김
김
김
김

 

질문을 종료한 이유: EditText의 버그 같습니다.
쎄미 (162,410 포인트) 님이 2021년 5월 17일 질문
쎄미님이 2021년 5월 20일 closed
...