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"
/>
</LinearLayout>
I don't want to use string in the second test. What should I do?
No problem that you are using the string hardcoded or not. If you want further information you could look: https://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"
/>
If you don't want this warning to bother you specifically on this View, you can use tools:ignore xml attribute to suppress it.
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Test"
tools:ignore="HardcodedText" />
Note that you can also add it to a parent element to suppress warnings on its children.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With