I have an Activity with some EditText fields and some buttons as a convenience for what normally would be used to populate those fields. However when we the user touches on
public class NonKeyboardEditText extends AppCompatEditText {
public NonKeyboardEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onCheckIsTextEditor() {
return false;
}
}
and add
NonKeyboardEditText.setTextIsSelectable(true);
The soft keyboard kept rising even though I set EditorInfo.TYPE_NULL
to the view.
None of the answers worked for me, except the idea I got from nik431's answer:
editText.setCursorVisible(false);
editText.setFocusableInTouchMode(false);
editText.setFocusable(false);
Let's try to set the below properties in your xml for EditText
android:focusableInTouchMode="true" android:cursorVisible="false".
if you want to hide the softkeypad at launching activity please go through this link
Simply Use
EditText.setFocusable(false);
in activity
or use in xml
android:focusable="false"
My test result:
with setInputType
:
editText.setInputType(InputType.TYPE_NULL);
the soft keyboard disappears, but the cursor will also disappear.
with setShowSoftInputOnFocus
:
editText.setShowSoftInputOnFocus(false)
It works as expected.
weekText = (EditText) layout.findViewById(R.id.weekEditText);
weekText.setInputType(InputType.TYPE_NULL);