Created
January 2, 2013 21:54
-
-
Save ecgreb/4438510 to your computer and use it in GitHub Desktop.
Sample code for back porting Android NumberPicker widget.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class NumberPickerWrapper { | |
static public NumberPickerWrapper createHolder(View view) { | |
NumberPickerWrapper numberPickerWrapper; | |
numberPickerWrapper = Build.VERSION.SDK_INT > 10 ? new NumberPickerWrapper_Sdk14() | |
: new NumberPickerWrapper_Sdk10(); | |
numberPickerWrapper.setView(view); | |
return numberPickerWrapper; | |
} | |
public abstract void setView(View view); | |
public abstract void setRange(int start, int end); | |
public abstract void setValue(int value); | |
public abstract int getValue(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumberPickerWrapper_Sdk10 extends NumberPickerWrapper { | |
private com.howaboutwe.ui.NumberPicker numberPicker; | |
@Override | |
public void setView(View view) { | |
numberPicker = (com.howaboutwe.ui.NumberPicker) view; | |
} | |
@Override | |
public void setRange(int start, int end) { | |
numberPicker.setRange(start, end); | |
} | |
@Override | |
public void setValue(int value) { | |
numberPicker.setCurrent(value); | |
} | |
@Override | |
public int getValue() { | |
return numberPicker.getCurrent(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumberPickerWrapper_Sdk14 extends NumberPickerWrapper { | |
private android.widget.NumberPicker numberPicker; | |
@Override | |
public void setView(View view) { | |
numberPicker = (android.widget.NumberPicker) view; | |
} | |
@Override | |
public void setRange(int start, int end) { | |
numberPicker.setMinValue(start); | |
numberPicker.setMaxValue(end); | |
} | |
@Override | |
public void setValue(int value) { | |
numberPicker.setValue(value); | |
} | |
@Override | |
public int getValue() { | |
return numberPicker.getValue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment