0
我有一個alertdialog,我表明,當用戶點擊了一個按鈕:鍵盤沒有出現自動
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();
}
}
我已經試過幾件事情,但鍵盤不會自動顯示出來。 它似乎也取決於設備以及與蜂窩星系標籤10.1,鍵盤顯示。但與銀河gio 2.3.6它不..
任何想法?
你試圖使用SHOW_FORCE?它的屏幕尺寸/設備特定和'android:imeOptions'(帶有flagNoFullscreen),可能你應該保持原樣,因爲系統對話框(例如wifi連接)可能表現相同。 – sandrstar