-
Notifications
You must be signed in to change notification settings - Fork 3.4k
English Documentation
|Method|Usage scenarios|Describe|Minimum version limit |---|---|---|---|---| |Builder(Context context, OnTimeSelectListener listener)|TimePicker&OptionsPicker|Construction method of builder|V3.0.1 |build()|TimePicker&OptionsPicker|return object|V3.0.1 |setOutSideCancelable(boolean cancelable)|TimePicker&OptionsPicker|Click the outside to dismiss|V3.0.1 |setDividerType(WheelView.DividerType dividerType)|TimePicker&OptionsPicker|Support FILL and WRAP|V3.0.6 |isDialog(boolean isDialog)|TimePicker&OptionsPicker|Dialog mode, default is false|V3.0.6 |setLayoutRes(int res, CustomListener customListener)|TimePicker&OptionsPicker|CustomLayoutRes,need add WheelView to the custom layout, otherwise will report null pointer exception, please refer to the demo|V3.0.7 |---|---|---|---|---| |TimePicker||||| |setType(TimePickerView.Type type)|TimePicker|Support six modes|V3.0.1 |gravity(int gravity)|TimePicker|default is center|V3.0.1 |setDate(Date date)|TimePicker|default is system date|V3.0.1 |setRange(int startYear,int endYear)|TimePicker|startYears and endYears|V3.0.1 |setLabel(String label_year, String label_month, String label_day, String label_hours, String label_mins, String label_seconds)|TimePicker|Label content ,you can set null or "" to hide it|V3.0.2 |isCyclic(boolean cyclic)|TimePicker|default is true|V3.0.1 |---|---|---|---|---| |OptionsPicker||||| |setCyclic(boolean cyclic1,boolean cyclic2,boolean cyclic3)|OptionsPicker|linkage|V3.0.1 |setSelectOptions(int option1, int option2, int option3)|OptionsPicker|default option|V3.0.1 |setLinkage(boolean linkage)|OptionsPicker|default is true|V3.0.1 |---|---|---|---|---| |Text||||| |setSubmitText(String Str_Submit)|TimePicker&OptionsPicker|Submit button text|V3.0.1 |setCancelText(String Str_Cancel)|TimePicker&OptionsPicker|Cancel button text|V3.0.1 |setTitleText(String Str_Title)|TimePicker&OptionsPicker|Title Text|V3.0.1 |---|---|---|---|---| |Color||||| |setSubmitColor(int Color_Submit)|TimePicker&OptionsPicker|Submit button text color|V3.0.1 |setCancelColor(int Color_Cancel)|TimePicker&OptionsPicker|Cancel button text color|V3.0.1 |setTitleColor(int Color_Title)|TimePicker&OptionsPicker|Title text color|V3.0.1 |setBgColor(int Color_Background_Wheel)|TimePicker&OptionsPicker|WheelView background color|V3.0.3 |setTitleBgColor(int Color_Background_Title)|TimePicker&OptionsPicker|Title background color|V3.0.3 |setDividerColor(int dividerColor)|TimePicker&OptionsPicker|divider color|V3.0.4 |setTextColorCenter(int textColorCenter)|TimePicker&OptionsPicker|the selected item text color|V3.0.4 |setTextColorOut(int textColorOut)|TimePicker&OptionsPicker|unselected item text color|V3.0.4 |---|---|---|---|---| |Size||||| |setSubCalSize(int Size_Submit_Cancel)|TimePicker&OptionsPicker|Submit and cancel button textSize|V3.0.1 |setTitleSize(int Size_Title)|TimePicker&OptionsPicker|the titleSize|V3.0.1 |setContentSize(int Size_Content)|TimePicker&OptionsPicker|Content textSize|V3.0.3 |setLineSpacingMultiplier(float lineSpacingMultiplier)|TimePicker&OptionsPicker|Limited to 1.2-2.0 multiple of maxTextHeight|V3.0.4
compile 'com.contrarywind:Android-PickerView:3.0.9'
//TimePicker
pvTime = new TimePickerView.Builder(this, new TimePickerView.OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date,View v) {//Callback
tvTime.setText(getTime(date));
}
})
.build();
pvTime.show();
//OptionsPicker
pvOptions = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int options1, int option2, int options3 ,View v) {
////Callback
String tx = options1Items.get(options1).getPickerViewText()
+ options2Items.get(options1).get(option2)
+ options3Items.get(options1).get(option2).get(options3).getPickerViewText();
tvOptions.setText(tx);
}
}).build();
pvOptions.setPicker(options1Items, options2Items, options3Items);
pvOptions.show();
If the default style does not meet your expectations, You can also customize attributes to apply
pvTime = new TimePickerView.Builder(this, new TimePickerView.OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date,View v) {//Callback
tvTime.setText(getTime(date));
}
})
.setType(TimePickerView.Type.ALL)//default all
.setCancelText("Cancel")
.setSubmitText("Sure")
.setContentSize(18)
.setTitleSize(20)
.setTitleText("Title")
.setOutSideCancelable(false)// default is true
.isCyclic(true)// default is false
.setTitleColor(Color.BLACK)
.setSubmitColor(Color.BLUE)
.setCancelColor(Color.BLUE)
.setTitleBgColor(0xFF666666)//Night mode
.setBgColor(0xFF333333)//Night mode
.setRange(calendar.get(Calendar.YEAR) - 20, calendar.get(Calendar.YEAR) + 20)//default 1900-2100 years
.setDate(new Date())// default is System time
.setLabel("year","month","day","hours","mins","seconds")
.build();
pvOptions = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int options1, int option2, int options3 ,View v) {
////Callback
String tx = options1Items.get(options1).getPickerViewText()
+ options2Items.get(options1).get(option2)
+ options3Items.get(options1).get(option2).get(options3).getPickerViewText();
tvOptions.setText(tx);
}
})
.setSubmitText("sure")
.setCancelText("cancel")
.setTitleText("title")
.setSubCalSize(18)
.setTitleSize(20)
.setTitleColor(Color.BLACK)
.setSubmitColor(Color.BLUE)
.setCancelColor(Color.BLUE)
.setTitleBgColor(0xFF666666)//Night mode
.setBgColor(0xFF444444)//Night mode
.setContentTextSize(18)
.setLinkage(false)
.setLabels("province", "city", "district")
.setCyclic(false, false, false)
.setSelectOptions(0, 0, 0) //default options
.setOutSideCancelable(false)//dismiss, default is true
.build();
pvOptions.setPicker(options1Items, options2Items, options3Items);