0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

My point was just adding the ":" after the string, kinda waist of code just to add two dots. Adding to the string.xml will make me add like age: and age

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.