Android - Weird behaviour with AlertDialog

392 Views Asked by At

I have an AlertDialog containing a ListView. One Item on the ListView has an EditText.
When cliking the EditText the keyboard won't show :

The code for EditText (I don't think that's what causing the issue)

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editableEditText"
    android:layout_weight="1"
    android:maxLines="1"/>
3

There are 3 best solutions below

1
On BEST ANSWER

try to add this code:

dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

should be the way. To me worked

EDIT:

this is another way i found:

 Dialog = builder.create(); Dialog.show(); 
    Dialog.getWindow().clearFlags( 
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 
    |WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); 
 Dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_‌​VISIBLE);
1
On

Try to use setSoftInputMode

Example code snippet -

AlertDialog.Builder b = new AlertDialog.Builder(this);
...

AlertDialog dialog = b.create();
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
dialog.show();
0
On

Try It

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);