Android uses GridView to realize the simple function of calendar

The simple calendar implementation only displays each month, without the functions of displaying the day and recording events

It mainly calculates the day of the week at the beginning of the month and the day of the week at the end of the month, and then displays the number of days in the previous month and the number of days in the next month.

Let's take a look at several tool classes used in date

Use a list to store every day. Considering that there are notes every day, we encapsulated a class. If you don't need it, you can directly a timestamp. After opening, first obtain the current timestamp, and then initialize to the first day of the current month through the method in the tool class. Then it is calculated, and the balance of last month, all of this month and next month are added to the list.

When setting each day, a field is set to whether it is this month. If yes, it is set to black, otherwise it is set to gray, which can be set in the getview method in the adapter.

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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>