Foreword: decided to begin to study the software development under the Android platform, take the calendar as the practice project, after a week, basically completes. In order to summarize and note, and for the need of friends for reference, began to organize this tutorial.
before you start :
Before you write a program, you need to design the project, because it is a practice project, primarily to determine the software UI interface, which is a completed screenshot:
For this picture, further decomposition:
The total is decomposed into three View files :
1:activity_main.xml
As the main screen for startup, when you create a new project, you build it first.
2:view_calendar_table.xml
Defines a monthly calendar view with the head fixed and other rows added dynamically by code.
3:view_calendar_day_cell.xml
Defines a view of each day, consisting mainly of three elements: Gregorian date, lunar calendar information, or whether it is today's tagged Image.
the corresponding code class definition :
Because to implement the left and right slider, the scenario here is to use Viewpager. Calendarpageradapter for Viewpager to provide multiple frame management, we designed the goal is to display the Gregorian calendar 1901-2,100 interval, the corresponding frame screen has (2100-1900) * 12 frames screen, if more to create, will occupy very large memory resources Source. will be managed by Viewpager, which determines when a frame is created and when it is destroyed to conserve memory resources. For more information please refer to: http://developer.android.com/reference/android/support/v4/view/ViewPager.html