I have an EditText in my application which is to only receive inputs from buttons I have placed on the screen.
To avoid the soft keyboard appearing I have a customised EditText class as follows:
public class CustomEditText extends EditText {
public CustomEditText(Context context) {
super(context);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
// Disables Keyboard;
public boolean onCheckIsTextEditor() {
return false;
}
}
This successfully stops the keyboard from appearing, however in ICS this approach also stops the Cursor from appearing.
setCursorVisible(true)
does not have any effect.
I've tried alternate methods of keeping the soft keyboard hidden, such as using android:editable="false"
and .setKeyListener(null);
but none of these solutions have ever worked in my tests. The keyboard always appears.
So, is there a way to return the cursor in ICS, while keeping the onCheckIsTextEditor override as it is?
I have finally found a (for me) working solution to this.
First part (in onCreate):
In addition, android:textIsSelectable needs to be set to true (or set in onCreate) and the EditText must not be focused on initialization. If your EditText is the first focusable View (which it was in my case), you can work around this by putting this just above it:
You can see the results of this in the Grapher application, free and available in Google Play.
Note/edit: It is not necessary to derive from EditText to create your own when using this method to prevent the cursor from being disabled.
why don't you try to disable soft key-pad like this
PINLockactivity.java
and for this EditText Field
xml code is
this is working fine with me for input security PIN with cursor.
i am taking input from button not keypad.