Android: how to permanently & completely NOT show default soft keyboard for an EditText?
<p>I have three EditText boxes in an activity, for two of which normal input methods (hard keys, default soft keyboard) are ok. But for one of the EditText boxes I want to send soft input only from a custom keyboard view. So in effect I want the default soft keyboard never to be shown for this EditText. I've tried adding onTouchListeners and onFocusChange listeners for the EditText with partial success like this:</p>

<pre><code>public boolean onTouch(View v, MotionEvent event) {
    v.requestFocus();
    imm.toggleSoftInput(0, 0);
    return true;
}

public void onFocusChange(View v, boolean hasFocus) {
    InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive(v)) {
        imm.toggleSoftInput(0,0);
    }
}
</code></pre>

<p>But I have not achieved a definitive solution because </p>

<p>1)the default soft keyboard always briefly flashes visible before the listener hides it</p>

<p>2)on some occasions, such as moving focus to the EditText with hard keyboard arrow keys sometimes sets the default soft keyboard visible</p>

<p>and so on.</p>

<p>So I would love to find a simple way to tell Android never to show the default soft keyboard for this specific EditText. I would not like to extend EditText and start to override stuff, since the EditText functionality is perfect for me - I just want the default soft keyboard not to be shown.</p>

<p>I've spent days now trying to figure this out. Some topics (including some here) found via google have half-way attempts at this problem, but so far I haven't found a single totally functional solution.</p>

<p>EDIT:</p>

<p>I'm really starting to get annoyed. I decided I could try not to use EditText but whatever other view that will get the job done. It turns out it is freakin hard to get rid of that soft keyboard. It even shows up when I use the hard keys to move focus from an EditText to a Button! Why on earth should the soft keyboard be shown on every freakin View that happens to have focus? Even when I explicitly say inputType="none"? How do I turn that <strong>*</strong> soft keyboard OFF? Below is the xml for the Button - let's use that as an example:</p>

<pre><code>&lt;Button
    android:id="@+id/OkButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="none"
    android:paddingRight="5mm"
    android:paddingLeft="5mm"
    android:layout_below="@id/Volume"
    android:layout_alignParentLeft="true"
    android:text="OK"/&gt;
</code></pre>

<p>EDIT2:</p>

<p>I have how achieved a solution that seems to work. First I get a hold of the InputMethodManager:</p>

<pre><code>this.imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
</code></pre>

<p>and the I set OnClickListener, OnTouchListener and OnFocusChange listener all call the following method when I want the EditText to be focused and my custom KeyboardView visible, while hiding the default soft input:</p>

<pre><code>private boolean makeActive(View v) {
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    EditText e = (EditText) v;
    int iType = e.getInputType();
    e.setInputType(InputType.TYPE_NULL);
    e.requestFocus();
    showKb();
    e.setInputType(iType);
    return true;
}
</code></pre>
