I\'m trying to deactivate the soft keyboard when using a NumberPicker to enter numerical values (for aesthetic reasons). This is my layout-xml-code:
Just enhanced the @MaxVogler 's ans (so if wannt vote this vote @MaxVogler too) and make it a robust hack. Also we dont need to call setOnFocusChangeListener
and setInputType
. Only setFocusable
to false will do.
Below is a helper api to enable/disable the feature
public static void enableNumberPickerManualEditing(NumberPicker numPicker,
boolean enable) {
int childCount = numPicker.getChildCount();
for (int i = 0; i < childCount; i++) {
View childView = numPicker.getChildAt(i);
if (childView instanceof EditText) {
EditText et = (EditText) childView;
et.setFocusable(enable);
return;
}
}
}