Search code examples
androidandroid-studiouser-interfaceandroid-edittextuser-experience

How do I select all the text in an editText after the user is finished typing in it?


I have an EditText with some dummy text in it. When the user finishes typing I want to be able to have all the text selected.

How can I achieve this?


Solution

  • You can use Rx's debounce to do that,

        RxTextView.textChanges(editText)
            .debounce(3, TimeUnit.SECONDS)
            .subscribe { textChanged: CharSequence? ->
                Log.d(
                    "TAG",
                    "Stopped typing!"
                )
                editText.selectAll()
            }