Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting increase/decrease interval of NumberPicker

Tags:

android

Is it possible to set the increase/decrease interval of NumberPicker to other value? For instance to 50 (50, 100, 150, 200, 250 etc)? Or do it require some customization/hack?

like image 945
Ismar Slomic Avatar asked Aug 12 '12 20:08

Ismar Slomic


People also ask

How do you find increasing and decreasing intervals?

Increasing and decreasing intervals are intervals of real numbers where the real-valued functions are increasing and decreasing respectively. To determine the increasing and decreasing intervals, we use the first-order derivative test to check the sign of the derivative in each interval.

Is the interval -∞ ∞ a strictly increasing interval?

Therefore, the interval (-∞, ∞) is a strictly increasing interval for f (x) = 3x + 5. Hence, the statement is proved. Example 3: Find whether the function f (x) x3−4x, for x in the interval [−1, 2] is increasing or decreasing.

When is a function increasing on an interval?

A function f (x) is said to be increasing on an interval I if for any two numbers x and y in I such that x < y, we have f (x) ≤ f (y). Which Function Does Not Have Increasing and Decreasing Intervals?

How do I Set my interval modifier in Anki?

Once you’ve determined what you want to set your Interval Modifier to in Anki, click on the gear icon next to your deck. Next, choose the “Review” tab at the top, and you’ll find Interval Modifier on the list. Don’t worry about the other ones for now.


1 Answers

I think you can do this:

  • Initialise a displayed array values for your picker :

    int NUMBER_OF_VALUES = 10; //num of values in the picker
    int PICKER_RANGE = 50;
    ...
    String[] displayedValues  = new String[NUMBER_OF_VALUES];
    //Populate the array
    for(int i=0; i<NUMBER_OF_VALUES; i++)
        displayedValues[i] = String.valueOf(PICKER_RANGE * (i+1));
    /* OR: if the array is easy to be hard-coded, then just hard-code it:
       String[] displayedValues = {"50", "100", "150", .....}; */
    
  • Set the displayed array to your picker :

    /* 
    NOTE: Your picker range has to be [0, displayedValues.size()-1] to be 
          consistent with the array index (displayedValues index).
    */
    //ToDo: Initialize the picker first.
    numPicker.setMinValue(0); 
    numPicker.setMaxValue(displayedValues.size()-1);
    numPicker.setDisplayedValues(displayedValues);
    
  • When you want to get/set the value of the picker :

    //To get the current value in the picker
    choosenValue = displayedValues[numPicker.getValue()]; 
    //To set a new value (let's say 150)
    for( int i=0; i<displayedValues.length ; i++ )
        if( displayedValues[i].equals("150") )
             numPicker.setValue(i);
    

Finally, there is a great easy-to-customize widget called android-wheel. You can check it out and use it if you like.

like image 111
iTurki Avatar answered Oct 12 '22 09:10

iTurki