##Do not concatenate text displayed with settext
prodNameView.setText("" + name);
prodOriginalPriceView.setText("" + String.format(getString(R.string.string_product_rate_with_ruppe_sign), "" + new BigDecimal(price).setScale(2, RoundingMode.UP)));
How do you suggest
Do not concatenate text displayed with setText. Do not concatenate text displayed with setText. Use resource string with placeholders.
When calling TextView#setText:
Never call Number#toString() to format numbers; locale-specific digits properly. it will not handle fraction separators and locale-specific digits properly. Consider using String#format with proper format specifications (%d or %f) instead.
Do not pass a string literal (e.g. “Hello”) to display text. Hardcoded text can not be properly translated to other languages. Consider using Android resource strings instead.
Do not build messages by concatenating text chunks. Do not build messages by concatenating text chunks. Such messages can not be properly translated.
Simply put, there are three things to keep in mind when using the setText method of a TextView.
If a number, use String#formatto modify
Special compilation, but use Android String36164; source file
Character set using+progress
##example in String36164;
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
Setting in textview by settext
hello.setText(getString(R.string.welcome_messages,"John",10));
##Refer to the problems in stackoverflow
Android official document
Similar Posts:
- [Solved] Android.content.res.Resources$NotFoundException: String resource ID #0x0
- [Solved] svn:Error output could not be translated from the native locale to UTF-8
- [Solved] Java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
- Eclipse’s shortcut Ctrl + Shift + F doesn’t work
- ToFixed, toexponential, toprecision in JS
- [Solved] Android Warning: android.content.res.Resources$NotFoundException: Resource ID #0x7f08010a
- [Solved] android.content.res.Resources$NotFoundException: String resource ID #0xffffff85
- Differences and relations between Java class library URI and URL
- CentOS Error: Failed to set locale, defaulting to C
- MySQL from_ Unixtime() and UNIX_ The difference of timestamp() function