安卓:删除输入从softkeyboard关键 [英] Android: Remove Enter Key from softkeyboard
问题描述
在我的登录表单,当用户点击一个EditText和presses回车键,这将插入新行,因此增加的EditText的大小。下一刻,它返回到previous的地方,并打印在密码字段点(这是下一个字段)。
In my login form when user clicks on an EditText and presses the enter key, this inserts a new line, therefore increasing the EditText's size. Next moment, it returns to its previous place and prints a dot in the password field (which is the next field).
我想删除从softkeyboard这个回车键。这可能吗?
I want to remove this enter key from the softkeyboard. Is it possible?
推荐答案
恐怕你不能做到这一点。但有一点是可以处理的KeyEvent softkeyboard这样,
I am afraid you can't do this. But one thing is you can handle the softkeyboard keyevents like this,
edittext.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN
&& event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
Log.i("event", "captured");
return false;
}
else if(event.getAction() == KeyEvent.ACTION_DOWN
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK){
Log.i("Back event Trigered","Back event");
}
}
}
return false;
}
});
除了这个,你必须要注意的是,提供的属性的android:单线= TRUE
将使你的EditText从当软keyborad ENTER规模越来越为pressed
Apart from this, you have to note that providing the attribute android:singleLine=true
will make your edittext from growing in size when the soft keyborad ENTER is pressed
这篇关于安卓:删除输入从softkeyboard关键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!