Android comes with CalendarView class implementation Calendar view

Source: Internet
Author: User

Article Origin: Learn the implementation of the Calendar control, Android3.0 the following version please consult other articles.

This article is mainly about the Android Calendar view Control CalendarView related content, and later will give a simple demo.

CalendarView inherited from Framelayout

Similar Java code examples that are referenced by other articles are as follows:

 Public classMainactivityextendsActivityImplementsOnclicklistener, Ondatechangelistener {PrivateCalendarView CalendarView; PrivateTextView Tvcalendar, Tvreminder, Tvnote, Tvmore; PrivateImageView Ivnext; PrivateImageView ivprevious; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);  This. Requestwindowfeature (Window.feature_no_title); Setcontentview (r.layout.activity_main);//InitData ();//Initui ();    }}
View Code

This part of the code works mainly in the load layout,calendarview is used when there are some default values, where the default is a little change, the interface to beautify.

The CalendarView part of the XML code is as follows:

    <LinearLayoutAndroid:layout_width= "Fill_parent"Android:layout_height= "Match_parent"Android:layout_weight= "8"android:orientation= "vertical" >        <CalendarViewAndroid:id= "@+id/calendarview"Android:layout_width= "Fill_parent"Android:layout_height= "Match_parent"Android:focusedmonthdatecolor= "@color/whitesmoke"Android:unfocusedmonthdatecolor= "@color/transparent"Android:selectedweekbackgroundcolor= "@color/transparent"Android:showweeknumber= "false"Android:weekseparatorlinecolor= "@color/transparent" />    </LinearLayout>
View Code

This is achieved by:

The above code leads to the use of the CalendarView class's property settings, to see in the settings are more used code:

Public methods
getDate () Gets the selected date in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
getdatetextappearance () Gets the text appearance for the calendar dates.
Getfirstdayofweek () Gets the first day of week.
Getfocusedmonthdatecolor () Gets the color for the dates in the focused month.
getmaxdate () Gets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
getmindate () Gets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
Getselecteddateverticalbar () Gets the drawable for the vertical bar shown at the beginning and at the end of the selected date.
Getselectedweekbackgroundcolor () Gets the background color for the selected week.
Getshowweeknumber () Gets whether to show the week number.
Getshownweekcount () Gets the number of weeks to is shown.
Getunfocusedmonthdatecolor () Gets the color for the dates in a not focused month.
getweekdaytextappearance () Gets the text appearance for the week day abbreviation of the calendar header.
Getweeknumbercolor () Gets the color for the week numbers.
Getweekseparatorlinecolor () Gets the color for the separator line between weeks.
isenabled () returns the active state of the view. Subclasses to explain their respective active states.
oninitializeaccessibilityevent (accessibilityevent event) Initializes events using information that is the view of the event source AccessibilityEvent . In other words, The change in the view state is the source that triggers the secondary event.
oninitializeaccessibilitynodeinfo (accessibilitynodeinfo info) initializes the object with information about the view AccessibilityNodeInfo .
setDate (long date) Sets the selected date in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
setDate (Long date, Boolean animate, Boolean center) Sets the selected date in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
setdatetextappearance (int resourceId) Sets the text appearance for the calendar dates.
setenabled (Boolean enabled) sets the available state of the view. Subclasses determine how the various available states of the view are displayed.
setfirstdayofweek (int firstdayofweek) Sets the first day of week.
setfocusedmonthdatecolor (int color) Sets the color for the dates of the focused month.
setmaxdate (long maxdate) Sets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
setmindate (Long mindate) Sets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in time getDefault() zone.
Setondatechangelistener (Calendarview.ondatechangelistener listener) Sets the listener to is notified upon selected date change.
Setselecteddateverticalbar (drawable drawable) Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.
setselecteddateverticalbar (int resourceId) Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.
setselectedweekbackgroundcolor (int color) Sets the background color for the selected week.
Setshowweeknumber (boolean showweeknumber) Sets whether to show the week number.
setshownweekcount (int count) Sets the number of weeks to be shown.
setunfocusedmonthdatecolor (int color) Sets the color for the dates of a is not focused month.
setweekdaytextappearance (int resourceId) Sets the text appearance for the week day abbreviation of the calendar header.
setweeknumbercolor (int color) Sets the color for the week numbers.
setweekseparatorlinecolor (int color) Sets the color for the separator line between weeks.

commonly used methods 摘借 (not my translation, thanks to the translation of Friends):

LongGetDate ();//get from 1970, January 1, 0 points 0 minutes 0 seconds to now the number of milliseconds, because the return is long type finally only until 2038    intGetfirstdayofweek ();//gets the day of the week, the Android123 hint returns the definition in the Java.util.Calendar class, such as Calendar.monday for Monday, which defines a value of 2.          LongGetmaxdate ();//gets the maximum number of days that CalendarView supports 1970 to that day         LongGetmindate ();//gets the minimum number of days that CalendarView supports 1970 to that day         BooleanGetshowweeknumber ();//gets whether the week number is displayed         BooleanIsEnabled ();//whether to display this calendar view          Public voidSetDate (LongDateBooleanAnimateBooleanCenter);//set the description of the selection date to 1970         voidSetDate (LongDate);//Set the selected date description to 1970         voidSetEnabled (BooleanEnabled);//set whether the view is enabled         voidSetfirstdayofweek (intFirstDayOfWeek);//set the number of days to start this week         voidSetmaxdate (Longmaxdate); voidSetmindate (Longmindate); voidSetondatechangelistener (Calendarview.ondatechangelistener listener);//The Calendar view modifies the interface, this introduction looks below.          voidSetshowweeknumber (BooleanShowweeknumber);//Set whether the week number is displayed
View Code

If you have more information, continue to add here

Android comes with CalendarView class implementation Calendar view

Related Article

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.