Android control's CalendarView Calendar dialog box

Source: Internet
Author: User

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
  1. Package com.example.test;
  2. Import Java.text.SimpleDateFormat;
  3. Import Org.holoeverywhere.widget.CalendarView;
  4. Import Org.holoeverywhere.widget.CalendarView.OnDateChangeListener;
  5. Import android.app.Activity;
  6. Import Android.os.Bundle;
  7. Public class Dateactivity extends Activity {
  8. CalendarView Calendar;
  9. @Override
  10. protected void OnCreate (Bundle savedinstancestate) {
  11. //TODO auto-generated method stub
  12. super.oncreate (savedinstancestate);
  13. Setcontentview (r.layout.date);
  14. Calendar = (CalendarView) Findviewbyid (R.id.calendar);
  15. Long nowtime = Calendar.getdate ();
  16. SimpleDateFormat f = new SimpleDateFormat ("yyyy mm month DD Day Hh:mm:ss");
  17. String time = F.format (nowtime);
  18. System.out.println ("-------------" + time);
  19. Calendar.setondatechangelistener (new Ondatechangelistener () {
  20. @Override
  21. public void Onselecteddaychange (CalendarView arg0, int arg1,
  22. int arg2, int arg3) {
  23. Arg2 = arg2 + 1;
  24. System.out.println ("-------------" + arg1 + "-" + arg2 + " -"
  25. + Arg3);
  26. }
  27. });
  28. }
  29. }

Show Results:

Reprinted by Bainiu.ltd from http://blog.csdn.net/wangjintao1988/article/details/8674408

Android control's CalendarView Calendar dialog box

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.