Reference: Http://stackoverflow.com/questions/33164886/android-textview-do-not-concatenate-text-displayed-with-settext
When TextView is dynamically updated to display data in activity, use:
Rgb_textview.settext (Settingdata.image_r + "," + Settingdata.image_g + "," + settingdata.image_b);
Then Android Studio will prompt: "Do not concatenate text displayed with Settext,use resource string with placeholders",
should read:
RGB_textview.setText(getString(R.string.RGB_value_string, settingData.Image_R, settingData.Image_G, settingData.Image_B));
<string name="RGB_value_string">%1$d,%2$d,%3$d</string>
It works fine without modification, but it's more canonical to modify it.
Common formats:
%n$s--->n that is currently the number of parameters (for example, 1 of%1 $ s represents the first parameter), s for the string
%n$d--->n that is currently the number of parameters (for example, 1 in%1$d for the first parameter), and D for an integer
%n$f--->n that is currently the number of parameters (such as 1 in%1$f for the first parameter), and F for floating-point numbers
When calling Textview#settext:
- Never call number#tostring () to format numbers; It would not handle fraction separators and locale-specific digits properly. Consider using String#format with proper format specifications (%d or%f) instead.
- does not pass a string literal (e.g. "Hello") to display text. hardcoded text can is properly translated to other languages. Consider using Android resource strings instead.
- Do not build messages by concatenating text chunks. Such messages can not be properly translated.
- Source: Https://stackoverflow.com/questions/33164886/android-textview-do-not-concatenate-text-displayed-with-settext
Source: http://www.bubuko.com/infodetail-1251094.html
From for notes (Wiz)
Android TextView: "Do not concatenate text displayed with SetText"