Suppose In my app I have two textview, first one name is ViewText and the second one is WordCount.
I want to show some text in ViewText and WordCount shows how many words in ViewText.

How can I count words in textview in Android Studio?
Suppose In my app I have two textview, first one name is ViewText and the second one is WordCount.
I want to show some text in ViewText and WordCount shows how many words in ViewText.

How can I count words in textview in Android Studio?
Try this one
val words = "Hi this is sentence for counting words"
var totalCount = words.split("\\s+".toRegex()).size
println(totalCount)