1

I am looking for a number picking like those used in the date controls on an Android and found this question: hour/minute picker for android countdown timer

Following that example I can get the controls I want - Yay! The problem is I don't see how to get the value the user selects? Normally I would set an on change listener and be happy, but how do I create a class that implements the internal interface com.android.internal.widget.NumberPicker$OnChangedListener? Is there another way to get the current selection?

Community
  • 1
  • 1
Ian Leslie
  • 841
  • 1
  • 9
  • 25
  • Do not use private APIs. We will not restrict you from doing it, but your code will be very likely to break on future platform versions or even on devices with the same platform version where the manufacturer has customized things. – adamp Nov 26 '10 at 17:13
  • Good point - since I am just writing a test project I am not to worried about that. OTOH perhaps I should just use a different way of entering values. – Ian Leslie Nov 26 '10 at 17:24

1 Answers1

0

Check the source code... Do you need a listener? getCurrent should give you the value. With reflection it would be something like:

Method m = c.getMethod("getCurrent");
int value = (Integer) m.invoke(o, foo);

EDIT: You can implement an interface that you got through reflection with java.lang.reflect.Proxy, see this question here.

Community
  • 1
  • 1
cristis
  • 1,986
  • 16
  • 22
  • Thank you - I found a web site with javadoc information for this class and it did not have a getCurrent method. I see from your link that it does. I'll try your suggestion when I get home. – Ian Leslie Nov 26 '10 at 17:26
  • Worked like a charm. For the record I'm just playing this this and will not be putting code like this into production as adamp says it is not good to use private APIs like this. – Ian Leslie Nov 27 '10 at 16:17