0

The first thing I did was in the onCreate(); method of my activity.

getWindow().setSoftInputMode(WindowManager().LayourParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

The second thing I did was in the manifest file.

android:windowSoftInputMode="stateAlwaysHidden"

But both of them didn't work! Still when I click on EditText. Keyboard APPEARS.

Before clicking Locationenter image description here

After clicking enter image description here

I don't want the keyboard at the background. What should I do?

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

0

Have you tried doing this?

View view = this.getCurrentFocus();
if (view != null) {  
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

This should remove keyboard of the view currently in focus

Martin Lund
  • 1,159
  • 9
  • 17
0

Implement OnTouchListener on your editText and set below properties

Hope this will help you

editTextEmail.setOnTouchListener(new View.OnTouchListener(){
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        int inType = editTextEmail.getInputType(); // backup the input type
        editTextEmail.setInputType(InputType.TYPE_NULL); // disable soft input
        editTextEmail.onTouchEvent(event); // call native handler
        editTextEmail.setInputType(inType); // restore input type
        editTextEmail.setFocusable(true);
        editTextEmail.setCursorVisible(false);
        return true; // consume touch even
    }
});
akhilesh0707
  • 6,709
  • 5
  • 44
  • 51
0

Try this. It works perfectly.

if (Build.VERSION.SDK_INT >= 11) {
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setTextIsSelectable(true);
} else {
    editText.setRawInputType(InputType.TYPE_NULL);
    editText.setFocusable(true);
}