How to prevent virtual keyboard displaying when long-press on EditText Widget?
<p>I've got an EditText widget in my app which I have set to read-only, and I want to know when the user long-presses on it. I don't want the virtual keyboard to popup if the user taps on this widget. </p>

<p>To stop the virtual keyboard from appearing, I'm using this:</p>

<p>EditText text = (EditText)findViewById(R.id.editText01);
editText.setClickable(false);</p>

<p>This works, but I can't get any long-press messages if I use OnLongClickListener().</p>

<p>Does anyone know how I can prevent the popup keyboard to appear, but still get long-press events?</p>

<p>Thanks.</p>

<p>EDITED: I actually tried the first two answers supplied to this question, and neither worked. What I ended up doing, was for the EditText widget I used the following:</p>

<pre><code>editText.setInputType(InputType.TYPE_NULL);
editText.setCursorVisible(false);
editText.setOnLongClickListener(mOnLongClickListener);
</code></pre>

<p>The setInputType() method call turns off clicks to the widget. The setOnLongClickListener() routine will handle all long-press events on the widget, and I return a true from that routine which basically consumes the long-press event. So, I now have an EditText widget that won't have the virtual keyboard popup when pressed, but a long-press on that widget will call my listener method.</p>
