代码拉取完成,页面将自动刷新
CalendarListview提供了一种日历选择日期的简便方法
allprojects{
repositories{
mavenCentral()
}
}
implementation 'io.openharmony.tpc.thirdlib:CalendarListview:1.0.2'
<com.andexert.calendarlistview.library.DayPickerView
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:id="$+id:pickerView"
ohos:height="match_parent"
ohos:width="match_parent"/>
DayPickerView dayPickerView = (DayPickerView) findComponentById(ResourceTable.Id_pickerView);
dayPickerView.setController(new DatePickerController() {
@Override
public int getMaxYear() {
// 日历将最大显示到此接口返回的年份
return 2023;
}
@Override
public void onDayOfMonthSelected(int year, int month, int day) {
// 每当用户选择一个新日期时,就会调用此接口
}
@Override
public void onDateRangeSelected(SimpleMonthAdapter.SelectedDays<SimpleMonthAdapter.CalendarDay> selectedDays) {
// 每当用户选择了两个日期,就会调用此接口,可以获取到这两个选中的日期
}
});
name | format | description | default_value |
---|---|---|---|
colorCurrentDay | Color | 当前日期的文字颜色 | 0xff999999 |
colorSelectedDayBackground | Color | 点击日期时指示器的背景色 | 0xffE75F49 |
colorSelectedDayText | Color | 点击日期的文字颜色 | 0xfff2f2f2 |
colorPreviousDay | Color | 当前月份过去日期的文字颜色 | 0xff999999 |
colorNormalDay | Color | 所有未过日期的文字颜色 | 0xff999999 |
colorMonthName | Color | 每个月的年月标题的文字颜色 | 0xff999999 |
colorDayName | Color | 每个月的星期的文字颜色 | 0xff999999 |
textSizeDay | dimension | 日期文字大小 | 16vp |
textSizeMonth | dimension | 每个月的年月标题的文字大小 | 16vp |
textSizeDayName | dimension | 每个月的星期的文字大小 | 16vp |
headerMonthHeight | dimension | 每个月的年月标题的高度 | 50vp |
selectedDayRadius | dimension | 点击日期指示器的半径尺寸 | 16vp |
calendarHeight | dimension | 每个月减去年月标题的高度 | 270vp |
enablePreviousDay | boolean | 启用当前月份的过去日期 | true |
currentDaySelected | boolean | 默认情况下选择当前日期 | false |
drawRoundRect | boolean | 指示器的形状是否为矩形 | false |
firstMonth | Integer | 开始显示的月份 | 当前日期的月份 |
lastMonth | Integer | 最后显示的月份 | firstMonth的前一个月 |
注意:如果你想使用colorPreviousDay
属性,需要先将enablePreviousDay
设置为false
通过DevEco studio,并下载SDK 将项目中的build.gradle文件中dependencies→classpath版本改为对应的版本(即你的IDE新建项目中所用的版本)
The MIT License (MIT)
Copyright (c) 2014 Robin Chutaux
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型