How to disable keyboard EditText and cursor functions ..?

I am making an application with my own keyboard and I want to disable the default android virtuul keyboard completely.

I've tried this:

 myEditText.setOnClickListener(new OnClickListener()
        {
            public void onClick(View v) 
            {
                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                 imm.hideSoftInputFromWindow(keresetEditText.getWindowToken(), 0);

            }
         });

      

This works well, but I accidentally ran into an error that really terrifies me to hell:

When I slide my finger over the EditText, only the soft keyboard appears! So the conclusion is: onClickListener just doesn't work while I slide rather than touch.

I tried onTouchListener but it just doesn't work! Any advice how can I disable the virtual keyboard completely? I don't need this in the whole application.

Another thing: I could ask another question for stackoverflow, but I think it makes sense here: When I click on the EditText cursor, I can move it to the text inside my EditText, but I don't want it to be included like that. Can I disable MOVEability cursors ??? So I need a blinking cursor, but just stopped completely.

+3


source to share


1 answer


Here are some solutions for you:



  • if you never need the onscreen keyboard to display in this action, you can set the attribute android:windowSoftInputMode="stateAlwaysHidden"

    in the manifest

  • disable edit text. You won't have a blinking cursor (or any cursor at all), but it will be impossible to open the soft keyboard with disabled edit text while keeping your own text in code

  • just use TextView setting android.R.drawable.edit_text as background. It will look like an EditText, but a read-only TextView allowing you to set any value from your code. Again, you still don't have a blinking cursor

  • set EditText's focusable and clickable attributes to false. Edit text will never receive focus, so it will never invoke the soft keyboard

  • (this is a hack) place an invisible button above the edittext, so a click on the edittext will actually be intercepted by the button, which does nothing. The edit text will still be focused with the trackball or direction keys and you still won't blink the cursor

+4


source







All Articles