How to capitalize the first letter of text in a TextView in an Android Application
I should be able to accomplish this through standard java string manipulation, nothing Android or TextView specific.
Something like:
String upperString = myString.substring(0, 1).toUpperCase() + myString.substring(1).toLowerCase();
Although there are probably a million ways to accomplish this. See String documentation.
EDITED
I added the .toLowerCase()
Following does not apply to TextView, but works with EditText; even then, it applies to the text entered from the keyboard, not the text loaded with setText(). To be more specific, it turns the Caps on in the keyboard, and the user can override this at her will.
android:inputType="textCapSentences"
or
TV.sname.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
This will CAP the first letter.
or
compile 'org.apache.commons:commons-lang3:3.4' //in build.gradle module(app)
tv.setText(StringUtils.capitalize(myString.toLowerCase().trim()));
StringBuilder sb = new StringBuilder(name);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
return sb.toString();