I am having some trouble preventing an EditText within an AlertDialog automatically obtaining focus and displaying the keyboard.
The presenting activity has windowSoftInputMode=stateHidden
and EditTexts within that don't get focus when the activity loads. But when the dialog is shown the keyboard automatically appears.
How do I prevent my AlertDialog from showing the keyboard when it is shown?
If you have a custom layout for your AlertDialog you can use a dummy view that get the focus instead of your edittext:
<!-- Dummy view -->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:focusable="true"
android:focusableInTouchMode="true"/>
Try to put that view before your edittext.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With