Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android :: Custom Dialog with number scrollable picker?

Tags:

android

dialog

PROBLEM

What we call this component in the red circle ??

and how can I make dialog that have it on like this.

actually I don't know what its called so I don't know keyword

to search about that. I'm sorry if it feel like weird question.

NOTE

I know how to create simple dialog in android anyway

enter image description here

like image 915
Jongz Puangput Avatar asked Jul 27 '14 01:07

Jongz Puangput


1 Answers

Imagine you want to have a NumberPicker that displays degree values from 0C to 20C.

You have to set a String array to populate your NumberPicker.

First, initialize your String [] with your values, like this:

    String [] degreesValues = new String [20];

    for(int i= 0;i<20;i++){
        degreesValues[i] = String.valueOf(i)+ (char) 0x00B0;
    }

Then, just apply that array on your NumberPicker, like this:

NumberPicker picker = (NumberPicker) findViewById(R.id.numberPicker);
    picker.setMinValue(0);
    picker.setMaxValue(19);
    picker.setDisplayedValues(degreesValues);
like image 154
joao2fast4u Avatar answered Nov 15 '22 00:11

joao2fast4u