How to hide keypad when editText is in focus

I want the editText box to be click-able so the user can scroll through the text, but I do not want the keyboard to appear. I have tried all these but they do not do what I want:

In XML:

android:editable="false"
android:windowSoftInputMode="stateAlwaysHidden"
android:inputType="none"

This disables it:

editText.setInputType(EditorInfo.TYPE_NULL); 

This only works on API 21 and above:

editText.setShowSoftInputOnFocus(false);

Answers


Try this

<EditText
        android:id="@+id/et_file_url"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="none"
        android:lines="1"
        android:textIsSelectable="true" />

Use these lines of code

  EditText editText= (EditText) findViewById(R.id.editText);
  InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);

Set an edit text on touch listener. This will make the edit text untouchable because it is set to return true.

   EditTextHere.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
          return true;
        }
    });

Make a statement that it will allow the user to touch edit text by returning it to false.


Need Your Help

Clean bindings with structs

objective-c cocoa macos struct cocoa-bindings

I have a model class for which it makes quite a lot of sense to have NSSize and NSPoint instance variables. This is lovely.

WordPress - MySQL Auto Increment User ID

mysql wordpress auto-increment sql-insert

I am looking to run two instances of WordPress which sync on a regular basis.