I have a very simple fragmentDialog with this layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/note"
android:layout_width="wrap_content"
android:layout_marginRight="25dp"
android:layout_marginLeft="25dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/post_it_note_area"
android:layout_width="match_parent"
android:layout_height="200dp"
android:textColor="@color/gray_text_primary"
android:textSize="16sp"/>
But when I type a number in the editText the keyboard will automatically close. From the log I get:
W/ViewRootImpl? Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_7, scanCode=0, metaState=0, flags=0x6, repeatCount=0, eventTime=1548366109, downTime=1548366109, deviceId=-1, source=0x0 }
W/IInputConnectionWrapper? showStatusIcon on inactive InputConnection
I'm running android 4.4.4 on a Moto X 2013. What cause this weird behavior? How can I avoid the keyboard hiding?
EDIT: It's not the keyboard that closes as I digit the number but the whole app (no crashes). I also noticed that the app closes when I type a number alone and not if I type a number near a letter: "hello a6" -> ok, "hello 6" -> closes immediatly). I added a textwatcher to the editText and none of the methods of the listener are triggered.. Please help me!
EDIT 2: I tried now with a Samsung S5 with Android 5 and the issue is not presenting, maybe something related to the Android version or the device?
EDIT 3: Bad news, the issue is presenting again on the S5 if I type the delete or the "Sym" keys.. Same as before, the app closes
Ok.. Finally I found what caused this behavior..
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
getActivity().finish();
return true;
}
});
return dialog;
}
I made this code for closing the dialogFragment pressing the back key and it's obviously buggy. Strange thing is that I would expect from thisto finish the activity typing any character..