0

I am creating a calculator app where i have an edittext where the result is shown.I want the data to be entered in the edit text only on clicking the number buttons NOT by the android keyboard.How do i disable the keyboard in my android app.Please help!

  • please do a search before posting a question. http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard – Spring Breaker May 15 '14 at 05:58
  • You can try like : Disable the `EditText` and append number to the `EditText` on the number `Button` click. – Apoorv May 15 '14 at 05:58

7 Answers7

2

Try

editText.setInputType(EditorInfo.TYPE_NULL)

Or

((EditText) findViewById(R.id.LoginNameEditText)).setFocusable(false);

Or

editText.setKeyListener(null);
Vinayak Bevinakatti
  • 38,839
  • 25
  • 103
  • 135
0

Try this :

InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Community
  • 1
  • 1
DDsix
  • 1,858
  • 15
  • 22
0

try below code:-

    EditText ed = (EditText)findViewById(R.id.editText1);

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  
    imm.hideSoftInputFromWindow(ed.getWindowToken(), 0);  

    ed.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  
            imm.showSoftInput(ed, InputMethodManager.SHOW_IMPLICIT);  

        }
    });

or

Window.SetSoftInputMode (SoftInput.StateAlwaysHidden);
duggu
  • 35,841
  • 11
  • 112
  • 110
0

If other situations you can prevent the keyboard showing simply using in the manifest

android:configChanges="orientation|keyboardHidden"

In this way the Android keyboard will not auto-open but is shown only if you click directly the EditText

Hybrid Developer
  • 2,239
  • 28
  • 49
0

Just posting an Answer what @yahya already commented.

You should consider using a TextView which is not editable and hence won't make any calls to the Keyboard.

In onClick() event of your button's call the setText(String) method and the apply the text you wish. :)

Ypu can also easily append things as setText(yourTextView.getText().toString + "Your New Text");

Atul O Holic
  • 6,216
  • 4
  • 36
  • 72
0

Hi Kindly try this: For this you no need any Widgets Context...

InputMethodManager miInputManager = (InputMethodManager) Activity.this
            .getSystemService(Context.INPUT_METHOD_SERVICE);
miInputManager.hideSoftInputFromWindow(Activity.this
            .getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);
Sivakumar
  • 613
  • 4
  • 9
-1

Use

android:windowSoftInputMode="stateHidden"

for <activity> in Android_Manifest.xml

Lal
  • 14,505
  • 4
  • 39
  • 63