-3

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.

Here is an example of my UI.

How can I count words in textview in Android Studio?

Dương Minh
  • 2,062
  • 1
  • 9
  • 21
Adev
  • 43
  • 1
  • 1
  • 7
  • I believe this answer will help: https://stackoverflow.com/questions/55426910/how-to-count-the-number-of-words-in-kotlin-android/55428548 – Ido Barnea Aug 25 '21 at 13:29

1 Answers1

0

Try this one

val words = "Hi this is sentence for counting words"
var totalCount = words.split("\\s+".toRegex()).size
println(totalCount)
Hardik Hirpara
  • 2,594
  • 20
  • 34