I have an EditText widget in my application that I installed read-only, and I want to know when the user clicks on it for a long time. I do not want the virtual keyboard to pop up if the user clicks on this widget.
To stop the virtual keyboard from appearing, I use the following:
Text EditText = (EditText) findViewById (R.id.editText01); editText.setClickable (false);
This works, but I cannot receive messages with a long press if I use OnLongClickListener ().
Does anyone know how I can prevent a pop-up keyboard from appearing, but still receive events with a long press?
Thanks.
EDITED: I actually tried the first two answers posed to this question, and none of them worked. What I ended up doing was for the EditText widget, I used the following:
editText.setInputType(InputType.TYPE_NULL);
editText.setCursorVisible(false);
editText.setOnLongClickListener(mOnLongClickListener);
Calling the setInputType () method disables clicks for the widget. In the setOnLongClickListener () method, all events with a long click on the widget will be processed, and I return the true value from this procedure, which basically consumes an event with a long click. So now I have an EditText widget that will not have a virtual keyboard popup when pressed, but a long press on this widget will call my listening method.
source
share