当前位置: 移动技术网 > IT编程>移动开发>Android > Android自定义酒店日期选择器

Android自定义酒店日期选择器

2020年03月09日  | 移动技术网IT编程  | 我要评论

皇冠夫妇吧,反应釜,李新良上将女儿李继红

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();

效果图:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网