xml 파일을 열어 Design탭 Palette에서 Component Tree로 textView추가하니 생겼다.

노란색 경고 이미지를 클릭해보면 경고 메시지를 확인하고 해결할 수 있다.

 

1) 경고 이미지

Component Tree 경고 이미지

 

 

 

2) 메시지

경고(Warning): 

Hardcoded text

Hardcoded string "TextView", 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

 

Hardcoded text

 

 

3) 해결

- Fix 버튼 클릭

 

Suggested Fix

 

- Resource name: textview -> title 입력

- Resource value: TextView -> MyTitle 입력 후 ok 버튼 클릭

 

 

- Component Tree 확인

 

 

4) xml 확인

app> res> values> strings.xml 확인

 

<resources>

    ...

    <string name="title">MyTitle</string>
</resources>

 

 

광고:

+ Recent posts