Giter Club home page Giter Club logo

android-pickerview's Introduction

##(原作者saiwu-bigkoo吴哥已经转行了,他已把项目转交给我维护,所以我会继续更新优化,不能白白荒废了,欢迎Pull Request,提issue。有兴趣的小伙伴可以加入QQ群:387051294 讨论交流)

介绍

一款仿iOS的PickerView控件,有时间选择和选项选择,并支持一二三级联动,支持自定义样式

  • 有时间和选项这两种选择器
  • 选项选择器支持三级联动
  • 时间选择器支持选择年份范围
  • 支持“年,月,日,时,分,秒”,“省,市,区”等选项的单位(label)显示、隐藏和自定义。
  • 支持自定义文字、颜色、文字大小等属性
  • 支持背景颜色更换,有夜间模式需求的问题可以解决了
  • Item的文字长度过长时,文字会自适应缩放到Item的长度,避免显示不完全的问题

——TimePickerView 时间选择器,支持年月日时分,年月日,年月,时分等格式
——OptionsPickerView 选项选择器,支持一,二,三级选项选择,并且可以设置是否联动

TimePicker.gif OptionsPicker.gif

有兴趣研究3D滚轮效果的实现机制,希望把源码研究透彻的可以看看这篇Android-PickerView系列之源码解析篇(二)

说明文档 Documentation(还在持续更新中)

V3.0.8版本更新说明(2017-3-7)

  • 修复timepicker只能在初始化时设置一次默认选中时间的问题

V3.0.7版本更新说明(2017-3-4)

  • 优化 起始终止年月日范围设置
  • 新增自定义布局

V3.0.6版本更新说明(2017-3-3)

  • 新增对话框模式
  • 新增timePicker “年月日时分”显示类型
  • 新增分隔线的显示类型选择(FILL、WARP)
  • 新增options默认选中项的调用方法(可重复设置);
  • 优化选中项显示位置有微小偏差问题

历史版本更新说明请查看Wiki

How to use

Gradle

compile 'com.contrarywind:Android-PickerView:3.0.8'
//compile 'com.bigkoo:pickerview:lunar.1.0'  Lunar Branch 农历分支

OR

Maven

<dependency> 
<groupId>com.contrarywind</groupId> 
<artifactId>Android-PickerView</artifactId>
<version>3.0.8</version>
<type>pom</type>
</dependency>

Sample usage:

//TimePicker
 pvTime = new TimePickerView.Builder(this, new TimePickerView.OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date,View v) {//选中事件回调
                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) {
                //返回的分别是三个级别的选中位置
                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(); 

详细使用请参考这里

效果图(招行信用卡的“掌上生活”里面条件选择器他们用的就是我这个库,大家可以当实际项目参考)

Thanks

#License

Copyright 2014 Bigkoo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-pickerview's People

Contributors

xiaosong520 avatar saiwu-bigkoo avatar totcw avatar greatgarlic avatar keluokeda avatar kyuyi avatar xxjy avatar

Watchers

lengguangzhishen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.