How to capitalize the first letter in custom textview?

Dhivyaseetha_Kumba picture Dhivyaseetha_Kumba · Aug 19, 2016 · Viewed 15.6k times · Source

In Custom TextView suppose if first character as a number then next character would be a character. How to find the first character amoung numbers.

Answer

Jocky Doe picture Jocky Doe · Jan 26, 2018

If you are using Kotlin you may go for:

Capitalize first word:

var str = "whaever your string is..."
str.capitalize()
// Whaever your string is...

Capitalize each word

var str = "whaever your string is..."
val space = " "
val splitedStr = str.split(space)
str = splitedStr.joinToString (space){
    it.capitalize()
}
// Whaever Your String Is...