A hard-coded string "Test" should use the @string resource

Hi guys, I'm new here, and this is my 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 do not want to use the string in the second test, what should I do?

+6
source share
2 answers

No problem that you use hardcoded string or not. If you want more information, you can see: fooobar.com/questions/129739 / ...

strings.xml

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

and use its linux layout file like

 <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/Test" /> 
+14
source

You can use hardcoded value, this is normal. If you want to remove the warning, you can go to Eclipse -> preference -> Android -> Lint Error Checking and look for "Hardcoded Text". Set to ignore, then Apply.

0
source

Source: https://habr.com/ru/post/922041/


All Articles