Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不好用,没有年月的选择。必须啊选择到日 #6

Open
DavidMGT opened this issue Mar 31, 2018 · 3 comments
Open

不好用,没有年月的选择。必须啊选择到日 #6

DavidMGT opened this issue Mar 31, 2018 · 3 comments

Comments

@DavidMGT
Copy link

不好用,没有年月的选择。必须啊选择到日

@xiaominglei001
Copy link

目前想到的办法,首先枚举增加一个类型
public enum DateType {

TYPE_ALL("yyyy-MM-dd E hh:mm"),//年、月、日、星期、时、分
TYPE_YMDHM("yyyy-MM-dd hh:mm"),//年、月、日、时、分
TYPE_YMDH("yyyy-MM-dd hh"),//年、月、日、时
TYPE_YMD("yyyy-MM-dd"),//年、月、日
TYPE_YM("yyyy-MM"),//年月
TYPE_HM("hh:mm");//时、分
private String format;

DateType(String format) {
this.format = format;
}

public String getFormat() {
return format;
}
}

然后DatePicker.java中也要适用这个类型
case TYPE_YM:
this.minuteView.setVisibility(GONE);
this.hourView.setVisibility(GONE);
this.weekView.setVisibility(GONE);
this.dayView.setVisibility(GONE);
this.monthView.setVisibility(VISIBLE);
this.yearView.setVisibility(VISIBLE);
break;

然后就有了年月的选项了

@geekxingyun
Copy link

geekxingyun commented Aug 23, 2018

感谢楼上提供的方案,楼主一直没更新,鄙人将这个问题的解决方案发布了一个新的版本

https://github.com/geekxingyun/PickTime

  1. 添加仓库

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

2.更换依赖

dependencies {
implementation 'com.github.geekxingyun:PickTime:v1.0.2'
}
3. 只显示年月调用代码

   DatePickDialog dialog = new DatePickDialog(this);

    //设置上下年分限制
    dialog.setYearLimt(5);

    //设置标题
    dialog.setTitle("选择时间");

    //设置类型
    dialog.setType(DateType.TYPE_YM);

    //设置消息体的显示格式,日期格式
    dialog.setMessageFormat("yyyy-MM-dd HH:mm");

    //设置选择回调
    dialog.setOnChangeLisener(null);

    //设置点击确定按钮回调
    dialog.setOnSureLisener(null);

    dialog.show();

楼主如果有空了,请发Email与我联系,我愿意将此改动给合并到此主仓库,否则我将继续维护这个仓库

@2e2ee95304418f96
Copy link

@geekxingyun 感谢, 偷懒地用了你的库.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants