Error

[Android][Warning] layout.xml 경고 : Hardcoded text

자판을 두드리다 2022. 9. 27. 13:24
320x100

[상황]

안드로이드 스튜디오에서 버튼을 생성하고

text를 입력했지만 경고가 확인됨

 

[참고 플랫폼]

더보기

1. Android Studio Bumblebee | 2021.1.1 Patch 2 | Runtime version: 11.0.11

 

[에러 내용]

Hardcoded text

Hardcoded string "Button Check", should use @string resource  Hardcoding text attributes directly in layout files is bad for several reasons:  * When creating configuration variations (for example for landscape or portrait) you have to repeat the actual text (and keep it up to date when making changes)  * The application cannot be translated to other languages by just adding new translations for existing string resources.  There are quickfixes to automatically extract this hardcoded string into a resource lookup.  Issue id: HardcodedText

 

[해결 방법]

하드 코딩의 경고 표시로

res / values / strings.xml 파일에서 직접 추가하거나

아래 이미지에 나오는 Fix 눌러서

key 값과 value 값을 입력 후 확인하면 될 것 같다

320x100