Alex VII
Alex VII

Reputation: 930

How can I stop keyboard opening?

In my app I want to fill my EditText by clicking Buttons; with my own keyboard. So I dont want that the keyboard opens if I click on the EditText. Is that possible?

Upvotes: 1

Views: 128

Answers (2)

Mayur Bhola
Mayur Bhola

Reputation: 735

Please try this code..
EditText editText = (EditText) findViewById(R.id.edit_text);
editText.setInputType(0);

OR

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

Upvotes: 3

user370305
user370305

Reputation: 109237

Either in manifest file..

<activity android:windowSoftInputMode="stateAlwaysHidden">

Or in your activity

InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);

Upvotes: 5

Related Questions