2222public class OptionPicker extends WheelPicker {
2323 protected ArrayList <String > options = new ArrayList <String >();
2424 private OnOptionPickListener onOptionPickListener ;
25- private int selectedOption = 0 ;
25+ private int selectedOptionIndex = 0 ;
2626 private String label = "" ;
2727
28- /**
29- * Instantiates a new Option picker.
30- *
31- * @param activity the activity
32- * @param options the options
33- */
3428 public OptionPicker (Activity activity , String [] options ) {
3529 super (activity );
3630 this .options .addAll (Arrays .asList (options ));
@@ -53,7 +47,7 @@ public void setLabel(String label) {
5347 */
5448 public void setSelectedIndex (int index ) {
5549 if (index >= 0 && index < options .size ()) {
56- selectedOption = index ;
50+ selectedOptionIndex = index ;
5751 }
5852 }
5953
@@ -93,11 +87,11 @@ protected View makeCenterView() {
9387 if (!TextUtils .isEmpty (label )) {
9488 labelView .setText (label );
9589 }
96- optionView .setItems (options , selectedOption );
90+ optionView .setItems (options , selectedOptionIndex );
9791 optionView .setOnWheelViewListener (new WheelView .OnWheelViewListener () {
9892 @ Override
9993 public void onSelected (boolean isUserScroll , int selectedIndex , String item ) {
100- selectedOption = selectedIndex ;
94+ selectedOptionIndex = selectedIndex ;
10195 }
10296 });
10397 return layout ;
@@ -106,39 +100,20 @@ public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
106100 @ Override
107101 public void onSubmit () {
108102 if (onOptionPickListener != null ) {
109- onOptionPickListener .onOptionPicked (selectedOption , options .get (selectedOption ));
103+ onOptionPickListener .onOptionPicked (selectedOptionIndex , options .get (selectedOptionIndex ));
110104 }
111105 }
112106
113- /**
114- * Gets selected option.
115- *
116- * @return the selected option
117- */
118107 public String getSelectedOption () {
119- return options .get (selectedOption );
108+ return options .get (selectedOptionIndex );
120109 }
121110
122- /**
123- * Get the selected position.
124- *
125- * @return the selected position
126- */
127111 public int getSelectedPosition () {
128- return selectedOption ;
112+ return selectedOptionIndex ;
129113 }
130114
131- /**
132- * The interface On option pick listener.
133- */
134115 public interface OnOptionPickListener {
135116
136- /**
137- * On option picked.
138- *
139- * @param position the position you selected
140- * @param option the option
141- */
142117 void onOptionPicked (int position , String option );
143118
144119 }
0 commit comments