如何知道关键presses中的EditText [英] how to know key presses in edittext
问题描述
我需要检测每个键preSS无论是软或硬键盘的EditText上。我只需要在同一时间发送的字符中的一个,因为他们是pssed $ P $,并不需要最后的文本字符串。
I need to detect every key press on either a soft or hard keyboard in EditText. I just need to send the characters one at a time as they are pressed and don't need the final text string.
我用用onkey preSS一个EditText都试过了,但碰到了问题,这里没有得到关键presses用软键盘。而textwatcher是不是一个好的选择,因为我需要每个键preSS。 有没有什么解决办法知道所有的主要presses(包括背部,移位,进入..还)
I have tried using an edittext with onkeypress, but ran into the problems here with not getting key presses with soft keyboards. and textwatcher isn't a good option because i need each key press. Is there any solution to know all the keypresses (including back,shift ,enter.. also)
推荐答案
如果你的EditText那么你可以使用TextWatcher interface.In我code search_edit 是的EditText。
if You have EditText then you can used TextWatcher interface.In my code search_edit is edittext.
search_edit.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//here is your code
myadapter.getFilter().filter(s);
listview.setAdapter(myadapter);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
这篇关于如何知道关键presses中的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!