0

Maybe a simple question - I need help to setText multiple strings from my strings.xml.

 mytext.setText(resources.getString(R.string.history_text1+R.string.history_text2));

So I mean I need to put 2 different text as one via one setText.

However with this syntax I have an error: android.content.res.Resources$NotFoundException: String resource ID #0xfe1e0079

2 Answers 2

2

Try this:

 mytext.setText(resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2))
Sign up to request clarification or add additional context in comments.

3 Comments

I tried it also this way but then I have a warning in Android Studio: Do not concatenate text displayed with setText. Use resource string with placeholders.. However I am using the placeholders... BUT seems it is working this way, just the warning is appearing
add empty string to string from resources mytext.setText("" + resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2))
that did not remove the warning. The answer from @forpas helped. But thanks anyway!
1

The values:
R.string.history_text1 and R.string.history_text2
are integer numbers referencing the actual strings in resources.
By adding them you get another integer that references nothing, so you get:

Resources$NotFoundException

If you want to concatenate the 2 string values:

String value = resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2)
mytext.setText(value);

Comments

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.