[Android] Kotlin에서 EditText 텍스트 설정

Happy Jiwon·2023년 11월 22일
1

Android

목록 보기
13/13

문제상황

EditText의 text를 설정하는데 에러가 발생

binding?.etSearch?.text = address // address type : String

원인

String 대신 Editable type이 들어가야 함

Editable
This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). If you make a DynamicLayout of an Editable, the layout will be reflowed as the text is changed.
내용과 마크업을 변경할 수 있는 텍스트에 대한 인터페이스

해결방법

저장할 문자열을 Editable형태로 바꿔서 넣어준다.

binding?.etSearch?.text = Editable.Factory.getInstance().newEditable(address)
profile
공부가 조은 안드로이드 개발자

0개의 댓글