问题描述
我尝试用 input.setImeOptions(EditorInfo.IME_ACTION_DONE)设置在softkeyboard完成按钮;
但完成按钮根本不显示在softkeyboard。
任何建议吗?
公共无效改性的(INT位置){
AlertDialog.Builder警报=新AlertDialog.Builder(MainActivity.this);
alert.setTitle(Modifica);
EditText上输入=新的EditText(MainActivity.this);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
alert.setView(输入);
最后编辑值= input.getText();
alert.setPositiveButton(OK,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){
Toast.makeText(getApplicationContext(),价值,Toast.LENGTH_LONG).show();
}
});
alert.setNegativeButton(取消,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){
// 取消。
}
});
alert.show();
}
这可能是因为你的输入域不是单成荫。
尝试添加
input.setSingleLine();
和您将看到pressing键盘将实际执行一个完成动作的动作键(即关闭键盘)
请参阅http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE
I try to set the "Done" button on the softkeyboard by using input.setImeOptions(EditorInfo.IME_ACTION_DONE);
but the "Done" button simply does not show on the softkeyboard.
Any suggestion please?
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();
}
It's probably because your input field is not single-lined.
Try adding
input.setSingleLine();
And you will see that pressing the action key of the keyboard will actually perform a 'done' action (i.e close the keyboard)
See http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#IME_ACTION_DONE
这篇关于setImeOptions:为什么"完成"按键不软键盘上的表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!