Solo
Solo

Reputation: 579

Close Android keyboard on start

I have a variable from xml:

editTextInput = (EditText) findViewById(R.id.editTextInput);

When the application loads the keyboard is shown, but I want to hide it, and if the user want to have it back she has to click on the EditText-field to display it.

Upvotes: 1

Views: 93

Answers (2)

Tarun
Tarun

Reputation: 13808

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Upvotes: 2

Tom Jackson
Tom Jackson

Reputation: 230

This should work:

 InputMethodManager inputManager = 
            (InputMethodManager) context.
                getSystemService(Context.INPUT_METHOD_SERVICE); 
    inputManager.hideSoftInputFromWindow(
            this.getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS); 

Upvotes: 0

Related Questions