The new Calendar view control in Android 3.0 can display grid-like calendar content, Android.widget.CalendarView is inherited from Android.widget.FrameLayout.
The CalendarView class provides a basic method for calendar setup,
Long GetDate () gets the number of milliseconds since 1970, January 1, 0 points 0 minutes and 0 seconds to now, since the return is a long type and ends only until 2038
int Getfirstdayofweek ()//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.
Long getmaxdate ()//Get CalendarView support the maximum number of days from 1970 to that day
Long getmindate ()//Get CalendarView support the minimum number of days from 1970 to that day
Boolean getshowweeknumber ()//Gets whether the week number is displayed
Boolean isenabled ()//Whether the Calendar view is displayed
public void SetDate (Long date, Boolean animate, Boolean Center)//Set the description of the selection date to 1970
void SetDate (long date)//Set selected date description to 1970
void SetEnabled (Boolean enabled)//Set whether the view is enabled
void Setfirstdayofweek (int firstdayofweek)//Set the number of days to start this week
void Setmaxdate (Long maxdate)
void Setmindate (Long mindate)
The code is as follows:
[Java]View PlainCopy
- Package com.example.test;
- Import Java.text.SimpleDateFormat;
- Import Org.holoeverywhere.widget.CalendarView;
- Import Org.holoeverywhere.widget.CalendarView.OnDateChangeListener;
- Import android.app.Activity;
- Import Android.os.Bundle;
- Public class Dateactivity extends Activity {
- CalendarView Calendar;
- @Override
- protected void OnCreate (Bundle savedinstancestate) {
- //TODO auto-generated method stub
- super.oncreate (savedinstancestate);
- Setcontentview (r.layout.date);
- Calendar = (CalendarView) Findviewbyid (R.id.calendar);
- Long nowtime = Calendar.getdate ();
- SimpleDateFormat f = new SimpleDateFormat ("yyyy mm month DD Day Hh:mm:ss");
- String time = F.format (nowtime);
- System.out.println ("-------------" + time);
- Calendar.setondatechangelistener (new Ondatechangelistener () {
- @Override
- public void Onselecteddaychange (CalendarView arg0, int arg1,
- int arg2, int arg3) {
- Arg2 = arg2 + 1;
- System.out.println ("-------------" + arg1 + "-" + arg2 + " -"
- + Arg3);
- }
- });
- }
- }
Show Results:
Reprinted by Bainiu.ltd from http://blog.csdn.net/wangjintao1988/article/details/8674408
Android control's CalendarView Calendar dialog box