17

I've tried to find the NumericUpDown button in Android, but failed. Do you know what the controller is called in Android - please let me know!

<?xml version="1.0" encoding="utf-8"?>
<!-- 
 main.xml 
 7/22 2010 
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >
 <GridView 
  android:id="@+id/GridView" 
  android:layout_width="fill_parent"  
  android:layout_height="fill_parent"
  android:numColumns="3"
  android:verticalSpacing="10dp"
  android:horizontalSpacing="10dp"
  android:columnWidth="90dp"
  android:stretchMode="columnWidth"
  android:gravity="center"
  android:background="@color/white"
  >
 </GridView>
 <ButtonUpDown>
  <!-- The real name is??? -->
 </ButtonUpDown>
</LinearLayout>

Thanx for your time Edit:

The controller looks like this: Numeric up down http://www.skogberg.eu/img/numUpDown.png

Benny Skogberg
  • 10,431
  • 11
  • 53
  • 83

5 Answers5

22

The view you have on your screenshot looks likes com.android.iternal.widget.NumberPicker which is used by some of the standard components, such as DatePicker.

Unfortunately, this component is not meant for public use - hence the internal in the package name. There are some tricks you can use to get to it, but I would recommend against accessing it directly. As this is "private" code the API maintainers aren't going to worry about external compatibility in different versions of Android, so even if you can get it working now it will probably cause your problems in future.

Your best bet is to get the code for NumberPicker from the public Android source repository and cut and paste it in to your own class to create your Number Picker widget.

Or if you didn't want to do this yourself, the work to pull NumberPicker from the source has already been done and posted on a website for you to download and use.

Community
  • 1
  • 1
David Webb
  • 190,537
  • 57
  • 313
  • 299
  • 2
    Has anybody submitted a patch to the Android team to do this officially yet? If not, someone should do that too, so future developers won't have to ask this question. – Jason Hall Jul 25 '10 at 07:45
7

It's available in SDK since API 11 - http://developer.android.com/reference/android/widget/NumberPicker.html

Rémi F
  • 1,327
  • 12
  • 25
3

This is an old question, but I will post this in case someone else finds this post:

As mentioned, NumberPicker is internal and not for public use. The safest way to use it to copy the source code from android source. Someone already did that and post it here:

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

Also see this for a discussion on same topic.

Community
  • 1
  • 1
Caner
  • 57,267
  • 35
  • 174
  • 180
2
<android.widget.NumberPicker
    android:id="@+id/numberPicker1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
</android.widget.NumberPicker>
Chuck D
  • 1,629
  • 2
  • 16
  • 32
1

Searching for android number picker came up with a few good results, particularly this thread which suggests that com.android.internal.widget.NumberPicker is what's used by the date picker widget. The thread has a few suggestions to go about using/emulating it.

Jason Hall
  • 20,632
  • 4
  • 50
  • 57