输入Google键盘的按键侦听器不起作用 [英] Enter key listener for Google keyboard is not working
本文介绍了输入Google键盘的按键侦听器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在不破坏默认换行符的情况下单击Google键盘的输入"键来添加功能.我已经使用过OnKeyListener,但是无法正常工作.
I want to add a functionality on click of "enter" key of Google's keyboard without vanquishing the default newline characteristic. I have used OnKeyListener but it is not working.
EditText edittext = (EditText) findViewById(R.id.user_query);
edittext.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode ==KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) {
//here i want to print numbers with next line in edit text
return true;
}
return false;
}
});
相同的代码可与其他键盘一起使用.
The same code is working with other keyboards.
推荐答案
查看全文