8

I have seen many examples with a pair of up and down arrows on NumberPicker, DatePicker and TimePicker of Android applications. But when I use it, application show no arrows.

Are there any tricks to make the arrows shown?

The SDK is API version 17 and revision 2.

The code is pretty simple.

<DatePicker
android:id="@+id/datePicker123"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:calendarViewShown="false" />

<TimePicker
android:id="@+id/timePicker123"
android:layout_width="280dp"
android:layout_height="wrap_content" />

<NumberPicker
android:id="@+id/numberPicker123"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

Activity onCreate

String[] options = new String[] { "A", "B", "C" }
NumberPicker numberPicker123 = (NumberPicker) findViewById(R.id.numberPicker123);
numberPicker123.setMinValue(0);
numberPicker123.setMaxValue(options.length - 1);
numberPicker123.setDisplayedValues(options);
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
OmniBus
  • 854
  • 1
  • 6
  • 25

2 Answers2

1

If you are looking to change the + and - in NumberPicker to up and down arrows it doesn't look like that is doable with the default NumberPicker class, from what I've seen in the documentation and from other questions I've seen answered on Stack Overflow.

Is it possible to make a horizontal NumberPicker?

Android having NumericUpDown Button?

It doesn't look like you get a lot of control over the class, but in the second question Dave Webb offers a lot of information on how to get the NumberPicker class from android. With the source, I'm sure you can change the images.

Otherwise, you can just make your own out of a linear layout with a number field and 2 buttons.

Hope this helps.

Community
  • 1
  • 1
Andrew T.
  • 4,598
  • 4
  • 35
  • 54
0

Try this..

btn.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {


                TimePickerDialog tp = new TimePickerDialog(MainActivity.this,
                        maxtime, 0,0, true);
                tp.show();
            }
});

And listener is..

TimePickerDialog.OnTimeSetListener maxtime = new OnTimeSetListener() {

        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            // TODO Auto-generated method stub
            textview.setText("" + hourOfDay + "/" + minute);
        }
    };

Hope it works..

AndiM
  • 2,196
  • 2
  • 21
  • 38
  • Although TimePickerDialog is not used in the application, your code is test in the application. The TimePickerDialog shows no up and down arrows. – OmniBus Apr 17 '13 at 06:25
  • It shows arrows in my case.I have just tried it for you.It works fine.If its not worked in your case then it would be better to use your custom up and down arrow button in your layout. – AndiM Apr 17 '13 at 06:32