GregorianLunarCalendar
GregorianLunarCalendar
?????+????????????????+???????
???
??????????
##?? ###????? ?????? GregorianLunarCalendar
?? NumberPicker
??????????????????
1.?? NumberPicker
????3???;
2. setValue()
????????????;
3.??fling????????
###???? ?????????? NumberPickerView
??????????? NumberPicker
???????????? NumberPickerView
????????? https://github.com/Carbs0126/NumberPickerView
???? GregorianLunarCalendar
???? NumberPickerView
?? NumberPicker
?????????????????? ???? NumberPicker
??????? setValue()
setMinValue()
setMaxValue()
setDisplayedValues()
????? NumberPickerView
???????????????? GregorianLunarCalendar
???????
##????? ###UI???????? 1.??????????????????????????????dayPicker?????????value???????????????????????????
2.????/??????/???????????????????????????????????????
###?????? 1.????????????????????????????????????????
2.?????????????????????????????????????????????
3.??????????????????2016?2?29??????????????????????????????
4.?????1901?-2100????????????
5.?1901??2100?????????????????
##?????
1.xml????
<cn.carbs.android.gregorianlunarcalendar.library.view.GregorianLunarCalendarView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:glcv_GregorianThemeColor="@color/colorGregorian"//??????
app:glcv_LunarThemeColor="@color/colorLunar"//??????
app:glcv_NormalTextColor="#FF777777"//????
app:glcv_ScrollAnimation="true"/>//?????????????true
2.java???????
//??View
GregorianLunarCalendarView mGLCView = (GregorianLunarCalendarView) this.findViewById(R.id.calendar_view)
//3?????????
//1.?????????????
mGLCView.init();
//2.???????????
mGLCView.init(Calendar c);
//3.?????????/????????????/?????????????????
// ??????Calendar???????Calendar??ChineseCalendar?GregorianLunarCalendarView??????????????
mGLCView.init(Calendar c, boolean isGregorian);
//?????
//??GregorianLunarCalendarView.CalendarData?????????????getCalendarData()??????date??
GregorianLunarCalendarView.CalendarData calendarData = mGLCView.getCalendarData();
//???????
Calendar calendar = calendarData.getCalendar();
//????ChineseCalendar??
//??????? ??2016?06?20? ???????????????????????
int yearG = calendar.get(Calendar.YEAR);
//????? 2016
int monthG = calendar.get(Calendar.MONTH) + 1;//????? 6
int dayG = calendar.get(Calendar.DAY_OF_MONTH);
//????? 20
int yearL = calendar.get(ChineseCalendar.CHINESE_YEAR);
//????? 2016
int monthL = calendar.get(ChineseCalendar.CHINESE_MONTH));
//????? 5//????????????-5
int dayL = calendar.get(ChineseCalendar.CHINESE_DATE);
//????? 20
//?????????
mGLCView.setOnDateChangedListener(new GregorianLunarCalendarView.OnDateChangedListener(){
@Override
public void onDateChanged(GregorianLunarCalendarView.CalendarData calendarData) {
Calendar calendar = calendarData.getCalendar();
String showToast = "Gregorian : " + calendar.get(Calendar.YEAR) + "-"
+ (calendar.get(Calendar.MONTH) + 1) + "-"
+ calendar.get(Calendar.DAY_OF_MONTH) + "\n"
+ "Lunar
: " + calendar.get(ChineseCalendar.CHINESE_YEAR) + "-"
+ (calendar.get(ChineseCalendar.CHINESE_MONTH)) + "-"
+ calendar.get(ChineseCalendar.CHINESE_DATE);
mChangedDate.setText(showToast);
}
}
);
3.????????
//???????????
<declare-styleable name="GregorianLunarCalendarView">
<attr name="glcv_ScrollAnimation" format="reference|boolean" />//?????????????????
<attr name="glcv_GregorianThemeColor" format="reference|color" />//??????
<attr name="glcv_LunarThemeColor" format="reference|color" />//??????
<attr name="glcv_NormalTextColor" format="reference|color" />//??????????
</declare-styleable>
??
sample????????????? IndicatorView
????????? https://github.com/Carbs0126/IndicatorView
##TODO ??????????????????????????????????????????????DatePicker????????????????????DatePicker???
License
Copyright 2016 Carbs.Wang (GregorianLunarCalendar) 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.