【发布时间】:2016-02-22 07:07:45
【问题描述】:
当用户单击操作栏中的图标时,会打开一个 AlertDialog 以保存数据。 要输入文件名,会出现一个软键盘。在这个键盘上,我想用 DONE 更改 ENTER 按钮。我应用了“.setImeOptions(EditorInfo.IME_ACTION_DONE);”但它不起作用。这是我的 AlertDialog 代码:
public void openSaveBox(){
final AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setTitle("OCRA score bewaren");
ad.setMessage("Geef een bestandsnaam in:");
final EditText input = new EditText(this);
ad.setView(input);
ad.setButton2("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String file = input.getText().toString();
bewaren(file);
ad.dismiss();
}
});
ad.setButton("Annuleren", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
ad.dismiss();
}
});
ad.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
ad.show();
}
我做错了什么?
【问题讨论】:
标签: android