1 Star 0 Fork 0

Zerlings / SmartDatePicker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

SmartDatePicker

SmartDatePicker是一款简单灵活的日期选择器,既能像DatePicker一样快速定义,又拥有和DatePickerDialog同样强大的功能。

Requirement

Kotlin / Java(需开启kotlin插件支持)

Android API 16+

1.0.0以上版本仅支持AndroidX

Usage

1.XML中定义

 <com.zerlings.datepicker.SmartDatePicker
        android:id="@+id/date_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:style="wheel_dark"
        app:format="yyyy-MM-dd"
        app:timeMills="false"
        app:minDate="2020-04-25"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
  • Note: format和minDate/maxDate需遵循标准格式,否则会报错。

2.Listeners

//Kotlin
date_picker.setOnDatePickListener { year, month, day, timeStamp, dateStr ->
    //todo
}
        
//Java
datePicker.setOnDatePickListener(new Function5<Integer, Integer, Integer, Long, String, Unit>() {
    @Override
    public Unit invoke(Integer integer, Integer integer2, Integer integer3, Long aLong, String s) {
        //todo
        return null;
    }
});

//Java with lambda
datePicker.setOnDatePickListener((year, month, day, timeStamp, dateStr) -> {
    //todo
    return null;
});
  • Note: 在Java中使用需要返回一个任意值

3.Attributes

name type info
format string 日期显示格式
minDate string 最小日期
maxDate string 最大日期
style enum 弹窗样式,可选轮盘或日历
timeMills boolean listener里的时间戳位数,false(默认)为10位,true为13位
  • Note: 控件本身(不包括弹窗)是一个TextView,可以使自定义字体、背景等样式。

Include

首先在项目根目录下的build.gradle中加入(已有则忽略):

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

然后在app文件夹下的build.gradle中引入:

dependencies {
    implementation 'com.gitee.Zerlings:SmartDatePicker:1.0.1'
}

License

MIT License

Copyright (c) 2020 Zerlings

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial    Copyright (c) 2020 Zerlings

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License Copyright (c) 2020 Zerlings Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一款简单灵活的日期选择器,既能像DatePicker一样快速定义,又拥有和DatePickerDialog同样强大的功能。 展开 收起
Android
MIT
取消

发行版 (5)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Android
1
https://gitee.com/Zerlings/SmartDatePicker.git
git@gitee.com:Zerlings/SmartDatePicker.git
Zerlings
SmartDatePicker
SmartDatePicker
master

搜索帮助

14c37bed 8189591 565d56ea 8189591