我尝试使用以下命令在软键盘上设置“完成”按钮input.setImeOptions(EditorInfo.IME_ACTION_DONE);
但“完成”按钮根本不显示在软键盘上。
请问有什么建议吗?
public void modif(int position) {
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setTitle("Modifica");
EditText input = new EditText(MainActivity.this);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
alert.setView(input);
final Editable value = input.getText();
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Toast.makeText(getApplicationContext(), value, Toast.LENGTH_LONG).show();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
}
这可能是因为您的输入字段不是单行的。
尝试添加
input.setSingleLine();
您将看到按下键盘的操作键实际上会执行“完成”操作(即关闭键盘)
See http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)