I do not want to setText("")
to clear the text.
I want to simulator the click action of right cross icon.
How to do it?
Asked
Active
Viewed 2,757 times
3

red23jordan
- 2,841
- 10
- 41
- 57
4 Answers
3
Based on the implementation of that icon, call setText(null)
on the TextInputEditText
.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
0
( Using Kotlin )
[your ID right cross icon].setOnClickListener {
[your ID edit text].text.clear()
}

Kelvin Herwanda Tandrio
- 120
- 1
- 9
0
(AutocompleteSupportFragment)
getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment).setText(null)
It will do exactly what the clear icon does.

red23jordan
- 2,841
- 10
- 41
- 57