Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capitalize the first letter in custom textview?

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.

like image 321
Dhivyaseetha_Kumba Avatar asked Nov 29 '22 00:11

Dhivyaseetha_Kumba


1 Answers

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...
like image 148
Jocky Doe Avatar answered Dec 04 '22 21:12

Jocky Doe