长按 Back Space 键时清除 editText 的内容 [英] clear the contents of the editText when long press on Back Space Key
本文介绍了长按 Back Space 键时清除 editText 的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因为我的 editext 是字符串格式,所以当我长按退格键时它不会清除所有文本.所以我正在寻找在长按退格键时清除所有文本的解决方案?
Because my editext is the string format it doesn't clear all the text when i long press on the backspace key. so i am looking for solution to clear all text when long press on the backspace key ??
推荐答案
你可以通过像
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
TextView myTextView = (TextView) findViewById(R.id.myTextView);
myTextView.setText("");
return true;
}
return super.onKeyLongPress(keyCode, event);
}
这篇关于长按 Back Space 键时清除 editText 的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文