Calendar project practice in android development tutorial (1)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.