All Projects → duanhong169 → Pickerview

duanhong169 / Pickerview

Licence: apache-2.0
🕘 Android滚动选择器(省市区联动选择、日期选择、时间选择)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pickerview

Vue Mj Daterangepicker
🗓Vue.js date range picker with multiples ranges and presets (vue 2.x)
Stars: ✭ 48 (-74.74%)
Mutual labels:  date-picker
Ngx Mydatepicker
Angular 2+ attribute directive datepicker
Stars: ✭ 123 (-35.26%)
Mutual labels:  date-picker
Brpickerview
BRPickerView 封装的是iOS中常用的选择器组件,主要包括:日期选择器(支持年月日、年月等15种日期样式选择,支持设置星期、至今等)、地址选择器(支持省市区、省市、省三种地区选择)、自定义字符串选择器(支持单列、多列、二级联动、三级联动选择)。支持自定义主题样式,适配深色模式,支持将选择器组件添加到指定容器视图。
Stars: ✭ 2,149 (+1031.05%)
Mutual labels:  pickerview
Bottomsheetpickers
Third-party date and time pickers for Android.
Stars: ✭ 1,099 (+478.42%)
Mutual labels:  date-picker
Datepicker
仿滴滴出行预约打车IOS风格3D时间选择器 🌲
Stars: ✭ 118 (-37.89%)
Mutual labels:  date-picker
Teapickerview
数据级联选择器、层级结构、多数据筛选、必藏 (Data Cascade Selector, Hierarchical Structure, Multiple Data Screening, Must Star)
Stars: ✭ 139 (-26.84%)
Mutual labels:  pickerview
Swifthuecolorpicker
iOS HUE color picker
Stars: ✭ 44 (-76.84%)
Mutual labels:  pickerview
Android Pickerview
This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
Stars: ✭ 13,003 (+6743.68%)
Mutual labels:  pickerview
Monthandyearpicker
The month and year picker for Android. Now you can pick month and year or only month or only year.
Stars: ✭ 118 (-37.89%)
Mutual labels:  date-picker
Vaadin Date Picker
The Web Component providing a date selection field with scrollable month calendar. Part of the Vaadin components.
Stars: ✭ 158 (-16.84%)
Mutual labels:  date-picker
Angular Mydatepicker
Angular datepicker and date range picker 📅
Stars: ✭ 76 (-60%)
Mutual labels:  date-picker
Date Picker
Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
Stars: ✭ 1,325 (+597.37%)
Mutual labels:  date-picker
React Calendar
Ultimate calendar for your React app.
Stars: ✭ 2,082 (+995.79%)
Mutual labels:  date-picker
Android Dial Picker
A custom rotating dial like picker for android
Stars: ✭ 56 (-70.53%)
Mutual labels:  pickerview
Vue Hash Calendar
移动端日期、时间选择插件,日期选择面板以日历形式展示。上下滑动切换周/月模式。支持两种模式:1,月模式,左右滑动切换月份。2、周模式,左右滑动切换周。
Stars: ✭ 163 (-14.21%)
Mutual labels:  date-picker
Stdpickerview
一个自定义的PickerView,兼容原生大部分接口,并支持更多的效果!
Stars: ✭ 46 (-75.79%)
Mutual labels:  pickerview
Nanocal
Airbnb range picker rip-off
Stars: ✭ 132 (-30.53%)
Mutual labels:  date-picker
Dpicker
A framework-agnostic minimal date picker
Stars: ✭ 187 (-1.58%)
Mutual labels:  date-picker
Mcpicker Ios
McPicker is a customizable, closure driven UIPickerView drop-in solution with animations that is rotation ready.
Stars: ✭ 186 (-2.11%)
Mutual labels:  pickerview
Django Bootstrap Datepicker Plus
Bootstrap3/Bootstrap4 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django version 2.2, 2.1, 1.11, 1.10 and 1.8
Stars: ✭ 156 (-17.89%)
Mutual labels:  date-picker

PickerView gitHub release platform Android Arsenal license Build status

Android滚动选择器

使用方法

1. 添加依赖

注:${latestVersion}请替换为当前最新版本号,见releases

gradle:

implementation 'com.github.duanhong169:picker-view:${latestVersion}'

maven:

<dependency>
	<groupId>com.github.duanhong169</groupId>
	<artifactId>picker-view</artifactId>
	<version>${latestVersion}</version>
	<type>pom</type>
</dependency>

2. 集成到项目中

2.1 集成PickerView

添加到layout文件中:

<top.defaults.view.PickerView
	android:id="@+id/pickerView"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"/>
使用列表作为数据源
List<Item> items = new ArrayList<>();
for (int i = 0; i < 42; i++) {
    items.add(new Item("Item " + i));
}

pickerView.setItems(Item.sampleItems(), item -> textView.setText(item.getText()));
实现Adapter作为数据源

配置数据源:

PickerView.Adapter adapter = new PickerView.Adapter() {

    @Override
    public int getItemCount() {
        return 42;
    }

    @Override
    public String getText(int index) {
        return "Item " + index;
    }
};
pickerView.setAdapter(adapter);

监听选择事件:

pickerView.setOnSelectedItemChangedListener((pickerView, previousPosition, selectedItemPosition) -> 
        textView.setText(pickerView.getAdapter().getText(selectedItemPosition)));

2.2 集成DivisionPickerView

添加到layout文件中:

<top.defaults.view.DivisionPickerView
    android:id="@+id/divisionPicker"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:preferredMaxOffsetItemCount="4"
    android:background="#e7e7e7"/>

构建省市区数据源:

参考Divisions.java

设置数据源并监听选择事件

final List<DivisionModel> divisions = Divisions.get(this);
divisionPicker.setDivisions(divisions);
divisionPicker.setOnSelectedDateChangedListener(division -> textView.setText(Division.Helper.getCanonicalName(division)));

2.3 集成DateTimePickerView

添加到layout文件中:

<top.defaults.view.DateTimePickerView
    android:id="@+id/datePickerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:preferredMaxOffsetItemCount="3"
    app:textSize="18sp"
    app:type="dateTime"
    app:minutesInterval="fifteen"
    app:curved="true"
    android:background="#e7e7e7"/>

设置初始日期:

dateTimePickerView.setStartDate(Calendar.getInstance());
// 注意:月份是从0开始计数的
dateTimePickerView.setSelectedDate(new GregorianCalendar(2017, 6, 27, 21, 30));

监听选择事件:

dateTimePickerView.setOnSelectedDateChangedListener(new DateTimePickerView.OnSelectedDateChangedListener() {
    @Override
    public void onSelectedDateChanged(Calendar date) {
        int year = date.get(Calendar.YEAR);
        int month = date.get(Calendar.MONTH);
        int dayOfMonth = date.get(Calendar.DAY_OF_MONTH);
        int hour = date.get(Calendar.HOUR_OF_DAY);
        int minute = date.get(Calendar.MINUTE);
        String dateString = String.format(Locale.getDefault(), "%d年%02d月%02d日%02d时%02d分", year, month + 1, dayOfMonth, hour, minute);
        textView.setText(dateString);
        Log.d(TAG, "new date: " + dateString);
    }
});

更详细的使用方法请参见示例。

License

Copyright 2018 Hong Duan

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].