赞
踩
嘿嘿,附上github地址,上面很详细。
https://github.com/Bigkoo/Android-PickerView
导入包后
如果是选择时间的如下:
TimePickerView timePickerBuilder=new TimePickerBuilder(Main2Activity.this, new OnTimeSelectListener() { @Override public void onTimeSelect(Date date, View v) { String formatType = "yyyy-MM-dd"; SimpleDateFormat dateFormat = new SimpleDateFormat(formatType, Locale.SIMPLIFIED_CHINESE); String huankuan_data = dateFormat.format(date); timer.setText(huankuan_data); } }).setType(new boolean[]{true, true, true, false, false, false})//分别代表是否显示,顺序为年月日时分秒 .setCancelText("取消") .setSubmitText("确定") .setTitleText("还款日期") .setOutSideCancelable(false) .isCyclic(false) // .setRangDate(startData,endData) .setTitleColor(Color.BLACK) .setSubmitColor(Color.parseColor("#FEB727")) .setCancelColor(Color.parseColor("#333333")) .isCenterLabel(false) .setLabel("年", "月", "日", "时", "分", "秒") .isDialog(false) .build(); timePickerBuilder.show();
//如果需要自定义的:
list = new ArrayList<>(); for (int i = 0; i < 30; i++) { list.add("提前"+(i+1)+"天"); } OptionsPickerView pickerView=new OptionsPickerBuilder(Main2Activity.this, new OnOptionsSelectListener() { @Override public void onOptionsSelect(int options1, int options2, int options3, View v) { oldtext.setText(list.get(options1)); } }).setSubmitText("确定")//确定按钮文字 .setCancelText("取消")//取消按钮文字 .setTitleText("提醒时间")//标题 .setTitleColor(Color.BLACK) .setSubmitColor(Color.parseColor("#FEB727")) .setCancelColor(Color.parseColor("#333333")) .setOutSideCancelable(false)//点击外部dismiss default true .isRestoreItem(true).build(); pickerView.setPicker(list); //如果选择列是两列或三列就选择可以放多个数据的方法 pickerView.show();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。