The NumberPicker widget is probably what you want. Unfortunatly it's located in com.android.internal.Widget.NumberPicker which we cannot get to through normal means.
There are two ways to use it:
- Copy the code from android source
- Use reflection to access the widget
Here's the xml for using it in a layout:
<com.android.internal.widget.NumberPicker
android:id="@+id/picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Here's the reflection to set the NumberPicker settings (I have not tested this):
Object o = findViewById(R.id.picker);
Class c = o.getClass();
try
{
Method m = c.getMethod("setRange", int.class, int.class);
m.invoke(o, 0, 9);
}
catch (Exception e)
{
Log.e("", e.getMessage());
}
Since it's an internal widget and not in the SDK, future compatibility could be broken if you use reflection. It would be safest to roll your own from the source.
The original source for this informaiton is here:
http://groups.google.com/group/android-developers/browse_frm/thread/65da9820998fddc9/6151cc9800e6a04d#6151cc9800e6a04d