I have an edittext, and when the user clicks this edittext I want to show an alertdialog.
My code is the following :
edt.setInputType(InputType.TYPE_NULL); edt.setFocusableInTouchMode(true); edt.requestFocus(); edt.setCursorVisible(false); edt.setOnClickListener(new OnClickListener() { public void onClick(View v) { CommentDialog.buildDialog(mContext, identifier, false, edt.getId()); } });
I don't want the keyboard to show up when the user clicks the edittext, so I set the inputtype to TYPE_NULL.
But when the edittext doesn't have focus and I click it, the onClick event isn't executed. When I click it a second time, the alertdialog shows up correctly.
How do I fix this?
Simply try to add this to your XML
file. Your keyboard pops up when widget
gains focus. So to prevent this behaviour set focusable to false
. Then normal use OnClickListener
.
<EditText android:focusable="false" ... />
Now, it should works.
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