Skip to content

Commit 6850d74

Browse files
committed
Show the keyboard when an EditTextDialog is shown.
1 parent 50e25f3 commit 6850d74

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

library/src/main/java/de/mrapp/android/dialog/decorator/EditTextDialogDecorator.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.view.LayoutInflater;
2323
import android.view.View;
2424
import android.view.Window;
25+
import android.view.WindowManager;
2526
import android.widget.Button;
2627
import android.widget.EditText;
2728

@@ -258,6 +259,21 @@ private void showErrorText(@Nullable final CharSequence errorText) {
258259
}
259260
}
260261

262+
/**
263+
* Requests the focus and displays the keyboard.
264+
*/
265+
private void requestFocus() {
266+
Window window = getWindow();
267+
268+
if (window != null) {
269+
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
270+
}
271+
272+
if (editText != null) {
273+
editText.requestFocus();
274+
}
275+
}
276+
261277
/**
262278
* Adapts the enable state of the dialog's positive button.
263279
*
@@ -620,6 +636,7 @@ protected final Map<ViewType, View> onAttach(@NonNull final Window window,
620636
final Void param) {
621637
inflateEditText();
622638
getDialog().addDialogValidator(this);
639+
requestFocus();
623640
return Collections.emptyMap();
624641
}
625642

0 commit comments

Comments
 (0)