How to stop the android soft keyboard from ever coming up in my entire application

前端 未结 5 673
广开言路
广开言路 2020-12-18 11:37

I\'m developing an application on a hardware device that has a built-in hardware keyboard that does not slide out so is always visible (like a blackberry). Therefore, I NEV

相关标签:
5条回答
  • 2020-12-18 12:02

    I solved it by overriding onCheckIsTextEditor method in my a-bit-custom EditText.

    @Override
    public boolean onCheckIsTextEditor() {
        return false;
    }
    
    0 讨论(0)
  • 2020-12-18 12:04

    Where ever you have Edit text, put this code..

    edittext.setInputType(InputType.TYPE_NULL);      
    if (android.os.Build.VERSION.SDK_INT >= 11)   
    {  
        edittext.setRawInputType(InputType.TYPE_CLASS_TEXT);  
        edittext.setTextIsSelectable(true);  
    }
    
    0 讨论(0)
  • 2020-12-18 12:07

    An easy workaround for tomorrow presentation:

    I would create a new IME with an empty view. Here are two openSource projects for you to look at some code.

    • GreekIME at googlecode
    • softkeyboard at googlecode

    If you want to know more about input methods, go to Creating an input method.

    0 讨论(0)
  • 2020-12-18 12:10

    Your application should not do anything. The device's firmware should contain a configuration that inhibits the soft keyboard based on the hardware keyboard being visible, just like every other Android device that has a hardware keyboard. If that is not happening, talk to the hardware maker and see if they are planning on addressing this.

    0 讨论(0)
  • 2020-12-18 12:22

    If an EditText has an inputType of 0, the soft keyboard will never pop up when that EditText is selected.

    EditText editText = findViewById(R.id.edit_text);
    editText.setInputType(0);

    This will of course need to be done for all the EditTexts in your application, or you could always subclass EditText and set the input type to 0 in your constructor.

    Setting the xml inputType parameter will not do, since that corresponds to a call to the setRawInputType method, which does not remove the KeyListener.

    0 讨论(0)
提交回复
热议问题