I have the following code:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:inputType="text"
android:maxLength="10"
android:textColorHighlight="#7cff88"
android:hint='@string/nome'
android:textColor="#ff0000"
android:textAlignment="center"
android:layout_weight="1"
>
></EditText>
Is there a way to set a double string in the hint? Something like @string/age & @string/name or @string/age : I am trying to add ´:´ without adding it to the string.xml file.
CodePudding user response:
You shouldn't do that. Why? Localization. To you, as an English speaker, "name:age" might make a lot of sense. It may not make sense in other languages. Other languages have syntactic rules that differ and may make it nonsensical or worse. Or it may have different words for the same concept in different contexts, and this will cause it to use the wrong one.
In general, you should never concatenate strings for display. You should always use a single parameterized string, and allow the translators to translate the entire thing in context. This minimizes the chance of a mistake.
Now if this is a personal app that will never be translated- no there's no ability to do that in xml, unless possibly via databinding. But I wouldn't suggest using databinding like that unless its an architectural decision that your entire app is going to invest into databainding.