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="[Link]
xmlns:tools="[Link]
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:
[Link]
[Link]
<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
[Link] 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
[Link] 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.
[Link] 03/10/2013