Android 键盘没有自动显示
当用户单击按钮时,我会显示一个alertdialog:Android 键盘没有自动显示,android,Android,当用户单击按钮时,我会显示一个alertdialog: public class CommentDialog { public static void buildDialog(final Context context, final String identifier, Boolean automaticKeyboard, final int idToUpdate) { AlertDialog.Builder alert = new AlertDia
public class CommentDialog {
public static void buildDialog(final Context context,
final String identifier, Boolean automaticKeyboard,
final int idToUpdate) {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setIcon(ViewBuilder.getDrawableFromDB("text.png"));
alert.setTitle("Commentaar");
// Edittext configuration//
final EditText input = new EditText(context);
String currentComment = EnteredValues.getInstance()
.getValueForIdentifier(identifier);
if (currentComment != null) {
input.setText(currentComment);
input.setSelection(currentComment.length());
}
input.setHint("Gelieve uw commentaar in te voeren.");
Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
input.setMinimumWidth(width);
input.setMaxLines(3);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
input.setFocusableInTouchMode(true);
input.requestFocus();
final InputMethodManager inputMethodManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(input,
InputMethodManager.SHOW_IMPLICIT);
// Add edittext to dialog
alert.setView(input);
// Set actions of dialog
alert.setPositiveButton("Bewaren",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
EnteredValues.getInstance().addValue(identifier, value);
View v = ShowScreenActivity.mActivity
.findViewById(idToUpdate);
EditText e = ((EditText) v);
e.setText(value);
e.setSelection(e.getText().length());
return;
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alert.show();
}
}
我试过几种方法,但键盘不会自动显示。
它似乎也依赖于设备,有了galaxy tab 10.1和蜂巢,键盘就出现了。但是2.3.6版本的galaxy gio没有
有什么想法吗?这可能有助于你尝试一下
<activity
android:name=".YourActivity"
android:windowSoftInputMode="stateHidden"> </activity>
您是否尝试过使用SHOW\u FORCE?它是屏幕大小/设备特定的和“android:imeOptions”(带有flagNoFullscreen),您可能应该保持原样,因为系统对话框(例如wifi连接)的行为可能与此相同。