Explore new DatePicker usage and explore datepicker

Source: Internet
Author: User

Explore new DatePicker usage and explore datepicker

DatePicker is rarely used. DatePicker is required for the project. when the project is used, it finds some changes with the previous ones. Repeat the usage of DatePicker.

First:

First, the usage of xml files:

Previously, the android: spinnersShown and android: calendarViewShown attributes were used to control whether DatePicker displays the scroll selector, calendar, or both.

Now, if you only write these two attributes, DatePicker always displays only the calendar and does not display the scroll selector.

The android: datePickerMode = "spinner" attribute is used together with the preceding two attributes to perfectly control the display form of DatePicker.

Here is my xml file:

<DatePicker        android:id="@+id/date_picker"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:calendarViewShown="false"        android:spinnersShown="true"        android:datePickerMode="spinner"        android:layout_gravity="center_horizontal"></DatePicker>
View Code

The Java code is as follows:

DatePicker datePicker = (DatePicker) view. findViewById (R. id. date_picker); Calendar c = Calendar. getInstance (); int year = c. get (Calendar. YEAR); int month = c. get (Calendar. MONTH); int day = c. get (Calendar. DAY_OF_MONTH); // initialize the DatePicker component and specify the listener datePicker during initialization. init (year, month, day, new DatePicker. onDateChangedListener () {@ Override public void onDateChanged (DatePicker datePicker, int I, int i1, int i2 ){}});
View Code

Note that when the system language is set to English, the format is month-day-year, and the system language is Chinese, and the format is year-month-day.

This is quite user-friendly. I would like to give a thumbs up to Google.

This basically satisfies my needs. I will study it later...

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.