0

I want to make something like this in android

value picker

this is a part of the datepicker, so How can i extract it to use only the value picker.

If it is not applicable to do this, tell me about any alternatives.

M.ElSaka
  • 1,264
  • 13
  • 20

2 Answers2

1

refer the links

http://www.quietlycoding.com/?p=5

http://www.technologichron.net/?p=42

similar questions asked here

Android Number Picker Dialog

Android dialog number picker

Community
  • 1
  • 1
KMI
  • 496
  • 4
  • 24
1

The standard android NumberPicker widgets looks exactly like that. Unfortunately, it's only available in Android 3.0 and up, so if you are targeting earlier versions, you will need to use a library.

Documentation for the android version can be found here.

Since others have already pointed you to possible libraries, I won't repeat that here. I'll show you how to use the standard NumberPicker for Android 3.0+.

In your xml layout (setting width to 100 dip allows for a three digit number, adjust according to your needs):

<NumberPicker
    android:id="@+id/numberpicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:width="100dip" />

In your code:

NumberPicker np = (NumberPicker) findViewById(R.id.numberpicker);  // get the widget
np.setMaxValue(10);                                                 // set the max value
np.setMinValue(0);                                                 // set the min value
np.setValue(5);                                                    // set initail display value
np.setWrapSelectorWheel(true);                                     // start over when reaching top or bottom

And a screenshot of it:

enter image description here

Barak
  • 16,318
  • 9
  • 52
  • 84