简体   繁体   中英

How to insert two or more R.string into one TextView

I want to insert two or more R.strings into one single textview. How do I do this? I know how to insert two direct strings into a single textview, separated by + such as below:

text1.setText("I am" + "John");

but to insert two or more R.strings, I can't debug it.

My attempt:

text1.setText(R.string.myname + R.string.John);

is not working. Does anyone know why?

你应该做

text1.setText(getString(R.string.myname) + getString(R.string.John));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM