2

I have an EditText object input which i am dynamically creating. I simply don't want the keypad to popup when i select the EditText object to enter text because i have made different buttons and set OnClickListner-s for all of them which will do the inputs but when the keypad pops up it covers the screen and i want to disable it because i don't want anyone to enter text from the keypad. i only want them to enter values from the buttons i have created.

Diptangsu Goswami
  • 5,554
  • 3
  • 25
  • 36

2 Answers2

3

You can disable showing the keyboard with this:

    editText.setInputType(InputType.TYPE_NULL);

And you can show it again with:

    editText.requestFocus();
    editText.setInputType(InputType.TYPE_CLASS_TEXT);

    final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    Handler handler = new Handler();
    Runnable r = new Runnable() {
        public void run() {
            imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
        }
    };
    handler.postDelayed(r, 100);
Cheese Bread
  • 2,246
  • 1
  • 13
  • 14
0

Try with setting android:inputType="none" in your edittext or following this thread

Disable keyboard on EditText

Community
  • 1
  • 1
Masum
  • 4,879
  • 2
  • 23
  • 28