Skip to content
Aige edited this page Jul 12, 2016 · 2 revisions

Notice:We will not provide technical support for WheelPicker Beta, the document only use for WheelPicker 1.1.0, please upgrade to 1.1.0 as soon as possible

Methods Overview

  • int getVisibleItemCount();
  • void setVisibleItemCount(int count);
  • boolean isCyclic();
  • void setCyclic(boolean isCyclic);
  • void setOnItemSelectedListener(WheelPicker.OnItemSelectedListener listener);
  • int getSelectedItemPosition();
  • void setSelectedItemPosition(int position);
  • int getCurrentItemPosition();
  • List getData();
  • void setData(List data);
  • void setSameWidth(boolean hasSameSize);
  • boolean hasSameWidth();
  • void setOnWheelChangeListener(WheelPicker.OnWheelChangeListener listener);
  • String getMaximumWidthText();
  • void setMaximumWidthText(String text);
  • int getMaximumWidthTextPosition();
  • void setMaximumWidthTextPosition(int position);
  • int getSelectedItemTextColor();
  • void setSelectedItemTextColor(int color);
  • int getItemTextColor();
  • void setItemTextColor(int color);
  • int getItemTextSize();
  • void setItemTextSize(int size);
  • int getItemSpace();
  • void setItemSpace(int space);
  • void setIndicator(boolean hasIndicator);
  • boolean hasIndicator();
  • int getIndicatorSize();
  • void setIndicatorSize(int size);
  • int getIndicatorColor();
  • void setIndicatorColor(int color);
  • void setCurtain(boolean hasCurtain);
  • boolean hasCurtain();
  • int getCurtainColor();
  • void setCurtainColor(int color);
  • void setAtmospheric(boolean hasAtmospheric);
  • boolean hasAtmospheric();
  • boolean isCurved();
  • void setCurved(boolean isCurved);
  • int getItemAlign();
  • void setItemAlign(int align);
  • Typeface getTypeface();
  • void setTypeface(Typeface tf);

All details of method above you can found in IWheelPicker

XML Attributes Overview

  • wheel_data
  • wheel_selected_item_position
  • wheel_item_text_size
  • wheel_item_text_color
  • wheel_selected_item_text_color
  • wheel_same_width
  • wheel_maximum_width_text
  • wheel_maximum_width_text_position
  • wheel_visible_item_count
  • wheel_item_space
  • wheel_cyclic
  • wheel_indicator
  • wheel_indicator_color
  • wheel_indicator_size
  • wheel_curtain
  • wheel_curtain_color
  • wheel_atmospheric
  • wheel_curved
  • wheel_item_align

Integrated into the project

Like most widget of Android system, once you integrated WheelPicker into your project, you can use it like common widget:

  • Used in XML
<com.aigestudio.wheelpicker.WheelPicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
  • Used in Java code
FrameLayout flContainer = (FrameLayout) findViewById(R.id.container);
WheelPicker wheelPicker = new WheelPicker(this);
FrameLayout.LayoutParams flParams = new FrameLayout.LayoutParams
        (ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
flParams.gravity = Gravity.CENTER;
flContainer.addView(wheelPicker, flParams);

WheelPicker will display a default data source by default:

If you want to set your own data source you just need invoke

void setData(List data);

and pass in a List, WheelPicker not limit type of data in List, but it will always cast data's type to String

List<Integer> data = new ArrayList<>();
for (int i = 1000; i < 3000; i++)
    data.add(i);
wheelPicker.setData(data);

Effect shown below:

The effect shown above maybe do not meet your design requirements, we offer a series of method to adjust WheelPicker's appearance, these methods is defined in IWheelPicker, you can find any details in that.

WheelPicker offer two ways to get data current item selected, the first is use getCurrentItemPosition, but it has certain limits, you must get the data when WheelPicker at rest, if you call this method when WheelPicker scrolling, you will get the data WheelPicker at rest last time; the second way is get data by listener, WheelPicker offer a OnItemSelectedListener to listen state when item selected, you can call setOnItemSelectedListener of WheelPicker set the listener for it, the method onItemSelected in OnItemSelectedListener will be called when WheelPicker stop:

public interface OnItemSelectedListener {
    void onItemSelected(WheelPicker picker, Object data, int position);
}

onItemSelected will pass WheelPicker object, data of current item selected, and data's position in data source

Widget

You can implement variety of Pickers through extends or combine multi WheelPicker, we will update more Pickers base on WheelPicker in the future and welcome you to join us development.

Clone this wiki locally