pchauhan / android-wheel

Automatically exported from code.google.com/p/android-wheel
0 stars 0 forks source link

Enhancement: Allow formatted string in NumericWheelAdapter #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Current NumericWheelAdapter implementation only takes an integer, then convert 
to string.  It would be nice if it could allow formatted string i.e. 
00,01,02,... as in minutes or even decimal.

It can be easily done by introducing an additional constructor to 
NumericWheelAdapter:

private String format = null;

public NumericWheelAdapter(int minValue, int maxValue, String format) {
    this.minValue = minValue;
    this.maxValue = maxValue;
    this.format = format;
}

// And modification to the getItem method:

public String getItem(int index) {
    if (index >= 0 && index < getItemsCount()) {
        if(this.format != null) {
            return String.format(this.format, minValue+index);
        } else {
            return Integer.toString(minValue + index);
        }
    }
    return null;
}

I'm attaching a new NumericWheelAdapter.java

Original issue reported on code.google.com by dzu...@gmail.com on 8 Nov 2010 at 3:01

Attachments:

GoogleCodeExporter commented 8 years ago
Done.
Thank you for the solution!

Original comment by yuri.kan...@gmail.com on 10 Nov 2010 at 7:27