Implementation of calender code for Android Custom Calendar
The product needs a check-in function. The check-in function is based on a calendar, so a calendar is customized according to requirements
I believe that all users of Android know about custom controls:
(1) First, create a class that inherits a container class or a control
(2) Then there are the attributes you need to set in the attrs folder
(3) Then it is to set properties and add layout and other functions in the class
In fact, there are not many problems with customizing a calendar. Many people will think of filling it through a GridView. It is true. It is mainly about displaying the position of the first day of each month and the number of days of each month.
Idea: fill the calendar by judging the current day of the week, but the filling size cannot be greater than the days of the current month. Judge from which position to fill the calendar by the day of the week on the first day of the current month.
code:
After the GridView is filled in, a simple calendar control is OK.
Demo: http://xiazai.jb51.net/201609/yuanma/AndroidCalenderDemo (jb51.net). rar
After you customize a calendar, you need to check in. Just modify it slightly in the customized calendar. See the effect picture below:
Look, this is OK, and then Demo: http://xiazai.jb51.net/201609/yuanma/AndroidCalender (jb51.net). rar
Demo with several methods added: http://xiazai.jb51.net/201609/yuanma/Calenderchange (jb51.net). rar
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.