在软键显示“完成”键
-
25-10-2019 - |
题
当将文本输入我的应用程序中的EditText时,我需要SoftKeyboard来显示“ DONE”键。在Android 2.1设备上,显示“完成”按钮,但在2.3或更高的情况下显示。
这是我使用的代码:
e.setImeOptions(EditorInfo.IME_ACTION_DONE);
e.setOnEditorActionListener(
new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH ||
actionId == EditorInfo.IME_ACTION_DONE ||
event.getAction() == KeyEvent.ACTION_DOWN &&
event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
Toast.makeText(getBaseContext(), e.getText().toString(), Toast.LENGTH_SHORT).show();
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(e.getWindowToken(), 0);
return true;
}
return false;
}
});
我正在使用Android 2.3.4版的三星设备。
EDITTEXT的屏幕截图:
解决方案
这不是Android版本的故障,而是您的设备使用的IME。三星(我认为是HTC的某些)IME永远不会将字母更改为“完成”或“ Next”或“ Go”。
不隶属于 StackOverflow