0

I am looking for a way to add a textview value to strings.xml file

I am not sure if this is possible,

I tried this code but it shows it as it is and it doesnt shows the value:

<string name="result">tvtxt1.getText()</string>
0

2 Answers 2

2

Ressources files xml like strings.xml can only be use for read only you cannot set values dynamically, you can see it like a final variable

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

Comments

0

When you provide a data as a Resource, it can't be modified during run time. This applies to Strings.xml, Drawables, Values etc.. You should consider to create a separate class and have your strings placed in this Class and access them.

I suggest to use a ViewModel, you can save your strings inside of it and you can be sure that you will not loose them when your view will be recreated for some reason

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.