如何在Android中以编程方式清除TextInputItemText

如何在Android中以编程方式清除TextInputItemText,android,android-textinputedittext,autocompletesupportfragment,Android,Android Textinputedittext,Autocompletesupportfragment,我不想用setText(“”)来清除文本。 我想模拟右十字图标的点击动作。 如何操作?基于,在文本输入文本上调用设置文本(null)使用: if (editText != null) { editText.getText().clear(); } (使用Kotlin) 参考: 它将完全执行清除图标的操作 [your ID right cross icon].setOnClickListener { [your ID edit text].text.clear() } (Aut

我不想用
setText(“”)
来清除文本。 我想模拟右十字图标的点击动作。 如何操作?

基于,在
文本输入文本上调用
设置文本(null)

使用:

if (editText != null) {

    editText.getText().clear();
}
(使用Kotlin)

参考:

它将完全执行清除图标的操作

[your ID right cross icon].setOnClickListener {
   [your ID edit text].text.clear()
}
(AutocompleteSupportFragment)
                getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment).setText(null)