安卓开源

日期和省份选择框

2016-04-21  本文已影响343人  极简coder

项目中很多都有日期选择框和省份选择框,然而安卓系统原生的选择框实在是不美观,很多公司UI只有IOS一套,安卓拿着自己看着写吧,效果什么的就按IOS那样来!也是无话可说了。

这是一个安卓的library,可以让你很快的应用IOS滚动选择的效果,看图
Github地址

datepick.gif

添加依赖

如果你使用AndroidStudio,在module的build.gradle文件添加依赖

compile 'com.brucetoo.pickview:library:1.1.1'

如果是eclipse,下载library导入并在主项目添加引用

使用方式

1.1.0版本
DatePickerPopWin pickerPopWin = new DatePickerPopWin(MainActivity.this, new DatePickerPopWin.OnDatePickedListener() { 
@Override 
public void onDatePickCompleted(int year, int month, int day, String dateDesc) { 
    //handler the result here 
    Toast.makeText(MainActivity.this,dateDesc,Toast.LENGTH_SHORT).show(); }
 });
1.1.1版本

新增了一些扩展属性,可以自定义开始年份及结束年份,比如不能选择当前日期之前的日期,初始化时候的日期,样式的修改等;

DatePickerPopWin pickerPopWin = new DatePickerPopWin.Builder(MainActivity.this, new DatePickerPopWin.OnDatePickedListener() {
 @Override 
 public void onDatePickCompleted(int year, int month, int day, String dateDesc) { 
    Toast.makeText(MainActivity.this, dateDesc, Toast.LENGTH_SHORT).show(); 
 } }).textConfirm("CONFIRM") //text of confirm button .textCancel("CANCEL") //text of cancel button 
     .btnTextSize(16) // button text size 
     .viewTextSize(25) // pick view text size
     .colorCancel(Color.parseColor("#999999")) //color of cancel button
     .colorConfirm(Color.parseColor("#009900"))//color of confirm button
     .minYear(1990) //min year in loop
     .maxYear(2550) // max year in loop
     .dateChose("2013-11-11") // date chose when init popwindow 
     .build();
上一篇下一篇

猜你喜欢

热点阅读