I making an application with my own keyboard and I want to completely DISABLE the android default virtual keyboard.
I tried this:
myEditText.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(keresetEditText.getWindowToken(), 0);
}
});
It is working very well, but accidently I just found an error that really bugs me to the hell:
When I slide down my finger on the EditText the soft keyboard just appear! So the conclusion is: the onClickListener just not running while i slide, and not tap.
I tried onTouchListener, but it just didn't work! Any tips how could I completely disable virtual keyboard ? I don't need it in the entire application.
Other thing: I could make an other question to stackoverflow but I think its logical here so: When I click on the EditText's cursor, i can move it in the text inside my EditText, but i dont want it to enabled like this. Can I disable the cursors MOVEability ??? So i need the blinking cursor but just totally in stayed position.
Here are few solutions for you:
if you will never need the softkeyboard to show on that activity, you can set the android:windowSoftInputMode="stateAlwaysHidden"
attribute in manifest
disable the edit text. You will not have the blinking cursor (or any cursor at all), but it will be impossible to open the soft keyboard using a disabled edit text, while still being able to set your own text in code
just use a TextView, while setting as background android.R.drawable.edit_text .It will look like an EditText, while only being a read-only TextView, still allowing you to set any value from code. Again, you still don't have the blinking cursor
set the EditText's focusable and clickable attributes to false. The edit text will never receive focus, thus never causing the soft keyboard to show
(this is a hack) place an invisible button over the edittext, so a click over the edittext will actually be intercepted by the button that does nothing. The edit text will still be focusable using the trackball or direction keys, and you still won't have the blinking cursor