I decided to start learning about software development on the Android platform and use calendar as a practical project. After one week, it was basically completed. In order to summarize and take notes, and learn from friends in need, I will start to sort out this tutorial.
Before getting started:
Before writing a program, you need to design the project, because it is a practice project, mainly to determine the software UI interface, which is a completed screen:
Further decomposition of this image:
This is divided into three View files.:
1: activity_main.xml
As the main screen to be started, it is generated first when a project is created.
2: view_calendar_table.xml
Defines the calendar view with a fixed header. Other lines are dynamically added by the Code.
3: view_calendar_day_cell.xml
Defines the view of each day. It consists of three elements: the date of the Gregorian calendar, the information of the lunar calendar, and whether the view is a marked image of today.
Corresponding code class definition:
To achieve sliding between the left and right screens, ViewPager is used. The CalendarPagerAdapter provides multi-frame management for ViewPager. Our design goal is to display the calendar in the range from 1901 to 2100. The corresponding frames have (2100-1900) x 12 frames, if it is created more, it will occupy a very large amount of memory resources. It is managed by ViewPager, which determines when a frame is created and destroyed to save memory resources. For more information, see: http://developer.android.com/reference/android/support/v4/view/ViewPager.html