Anda di halaman 1dari 2

android layout - Hardcoded string "Test", should use @string resource - Stack Over...

Página 1 de 2

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no
Tell me more ×
registration required.

Hardcoded string “Test”, should use @string resource

Hi guys I'm new here and this is my very first problem

here is my code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ref"
/>

<TextView

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Test"
/>

I don't want to use string in the second test what should i do ?

android-layout

asked Aug 3 '12 at 11:51


Edli
11 1 2

1 Answer

No problem that you are using the string hardcoded or not. If you want further information you could look:
http://stackoverflow.com/a/8743887/1517996

strings.xml

<resources>
<string name="Test">Test</string>
<resources>

and use it lin layout file like

<TextView

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Test"
/>

edited Aug 3 '12 at 13:21 answered Aug 3 '12 at 11:56


CodersParadise
477 1 10

I already saw that link but i dont want any error on my code :/ is there any way to avoid this error ? – Edli Aug
3 '12 at 13:14

http://stackoverflow.com/questions/11795206/hardcoded-string-test-should-use-string... 03/10/2013
android layout - Hardcoded string "Test", should use @string resource - Stack Over... Página 2 de 2

this is not an error, this is a warning. If you dont want this warning you should implement your "Test" string in
strings.xml as <string name="Test">Test</string> and use it like <TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/Test" /> please see my edited post –
CodersParadise Aug 3 '12 at 13:20

Thanks alot !!! You really help me – Edli Aug 3 '12 at 13:51

:) If it is correct please mark as an answer. – CodersParadise Aug 3 '12 at 14:06

1 Why wasn't this answer accepted? – Aaron Russell Apr 26 at 17:27

Not the answer you're looking for? Browse other questions tagged android-layout or
ask your own question.

http://stackoverflow.com/questions/11795206/hardcoded-string-test-should-use-string... 03/10/2013