Is there a way to permanently hide the soft keyboard, but keep focus for EditText?

In my Android app, I have 3 EditTexts in my one action. I created my own digital panel in my work. Whenever I click on any EditText, a soft keyboard appears. I want to block it forever for this action, but if the user touches EditText, then he should be in focus. As the cursor blinks. Any idea how I can do this? Thanks in advance.

+4
source share
4 answers

Manually hiding the keyboard

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    YourEditText.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            // TODO Auto-generated method stub
            mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);

        }
    });
      YourEditText.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mgr.hideSoftInputFromWindow(v.getWindowToken(), 0);

        }
    });
+4
source

I will check myself. his work is right. InputMethodManager imm;

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

    imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

   edittext1.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

     imm.hideSoftInputFromWindow(edittext1.getWindowToken(), 0);
        }
    });
0

hideSoftInputFromWindow() EditText, , . , - LinearLayout, Then,

linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
    /* Hide keyboard from this activity permanently */
    InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.hideSoftInputFromWindow(linearLayout.getWindowToken(),0);

xml

<EditText 
android:focusable="false"

.../" >

edittext

0
Android , . EditText.
private void hideKeyboard(EditText editText){
    editText.setShowSoftInputOnFocus(false);
}
0

All Articles