I have copied Android's NumberPicker widget to my own application, but I'm having one problem...
When someone manually clicks the EditText and changes it via the keyboard, the selection is not saved. Is there some listener that I can implement to check and see if the user manually changes the EditText to set it as current? Or something?
I found this solution lost somewhere in android-developers google group:
For android SDK NumberPicker widget, simply use:
myNumberPicker.clearFocus();
before you try to get its value. When you have an activity with only the NumberPicker and maybe a button or a spinner, and you edit it and try to click elsewhere, its onFocusChangedListener is not handled properly. So you just need to force it to lost focus before using getValue(). Worked like a charm to me.
I used the Michael Novak number picker. Although onEditorAction was already implemented it didn't properly set the input. The easy fix for me was to call validateInput on the textView in getCurrent.
/**
* @return the current value.
*/
public int getCurrent() {
validateInput(mText);
return mCurrent;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With