예를 들어, 안드로이드에 view 추가시
Hardcoded string "left", should use @string resource
이런 유형의 경고가 뜨는 경우가 있다.
말그대로 오류가 아닌 경고이므로 그냥 무시해도 앱 실행에는 문제가 없어보이지만 그래도 꺼리짐한것은 사실이다..-_-
Hardcoded string "left", 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. |
안드로이드 앱에서는 문자열을 직접 지정보다는 리소스를 이용해서 사용하는것을 권장하고 있다고 한다. 그래서 res/values/strings.xml 경로에 변수를 추가후에 해당 변수를 갖다쓰는 방법을 권하고 있는데...
경고창 하단에 위처럼 Fix 버튼이 있다. 저것을 누르고 팝업에서 확인누르면 알아서 strings.xml 에 추가가 된다. 아래처럼 말이다.
위 경우는 left 를 변수로 지정하지 않아서 그에대한 경고창이 띄어진것이었는데 Fix를 누르니 자동으로 안드로이드 스튜디오가 strings.xml 에 변수를 추가해줬다.
이런 경고창이 뜨는 분들은 참고하면 좋을것이다.
'프로그래밍 > 안드로이드' 카테고리의 다른 글
[안드로이드] Buttons in button bars should be borderless 현상 (0) | 2021.08.03 |
---|---|
[안드로이드] layout 오류 - Could not initialize class android.support.design.widget.CoordinatorLayout (0) | 2021.08.03 |
[안드로이드] Infer Constraints (0) | 2021.08.03 |
[안드로이드] Activity layout 이 안보이는 현상 (0) | 2021.08.03 |