How to capitalize the first letter of text in a TextView in an Android Application

前端 未结 11 1788
孤街浪徒
孤街浪徒 2020-12-23 15:35

I\'m not referring to textInput, either. I mean that once you have static text in a TextView (populated from a Database call to user inputted data (that may not be Capitaliz

11条回答
  •  青春惊慌失措
    2020-12-23 16:27

    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()

提交回复
热议问题