android开发分享Android自定义酒店日期选择器

android自定义日期区间选择器,类似于途家等酒店、旅游日期区间选择器: 重写popupwindow 制定区间日历 添加日历日期选中监听 封装插件化

android自定义日期区间选择器,类似于途家等酒店、旅游日期区间选择器:

  • 重写popupwindow
  • 制定区间日历
  • 添加日历日期选中监听
  • 封装插件化
  • github开源

customdatepicker

类似于途家等酒店日期选择器,弹出自定义的popupwindow,监听日期选中,返回结果。代码已经开源到github上,提供插件化。 —— [ wiki ]

github 地址:customhotelcalender 

1. 添加依赖:

 step 1.add it in your root build.gradle at the end of repositories:

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

step 2. add the dependency

  dependencies {      implementation 'com.github.atuan07:customhotelcalender:v1.0.2'    }

2.使用方法:

  private int startgroup = -1;//全局量  private int endgroup = -1;  private int startchild = -1;  private int endchild = -1;    ...       new datepopupwindow        .builder(mainactivity.this, calendar.getinstance().gettime(), view)//初始化        .setinitselect(startgroup, startchild, endgroup, endchild)//设置上一次选中的区间状态        .setinitday(false)//默认为true,ui内容为共几天、开始、结束;当为false时,ui内容为共几晚、入住、离开        .setdateonclicklistener(new datepopupwindow.dateonclicklistener() {//设置监听          //点击完成按钮后回调返回方法          @override          public void getdate(string startdate, string enddate, int startgroupposition, int                     startchildposition, int endgroupposition, int endchildposition) {            startgroup = startgroupposition;//开始月份位置            startchild = startchildposition;//开始对应月份中日的位置            endgroup = endgroupposition;//结束月份位置            endchild = endchildposition;//结束对应月份中日的位置            string mstarttime = calendarutil.formatdateymd(startdate);            string mendtime = calendarutil.formatdateymd(enddate);            result.settext("您选择了:" + mstarttime + "到" + mendtime);          }        }).builder();

效果图:

Android自定义酒店日期选择器

以上就是android开发分享Android自定义酒店日期选择器的全部内容,希望对大家的学习有所帮助,也希望大家多多支持<计算机技术网(www.ctvol.com)!!>。

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/addevelopment/899388.html

(0)
上一篇 2021年10月23日
下一篇 2021年10月23日

精彩推荐