Android Chinese API (60) -- DatePicker. OnDateChangedListener

Source: Internet
Author: User

 

Preface

This chapter is about android. widget. DatePicker. OnDateChangedListener. The version is Android 2.3 r1 and translated from "cnmahj". Welcome to his blog: http://p.toolib.com/step. Thank you again "cnmahj "! Welcome to join in Android API Chinese translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://code.taobao.org/project/view/404/

 

Body

I. Structure

Public static interface DatePicker. OnDateChangedListener

Direct subclass

DatePickerDialog

 

Ii. Overview

Indicates that the user has changed the date callback function.

 

Iii. Public Methods

Public abstract void onDateChanged (DatePicker view, int year, int monthOfYear, int dayOfMonth)

(Note: The onDateChanged () date will be called)

Parameters

View associated with the listener.

Year indicates the year set by the user.

The month (0-11) set by the monthOfYear user, andCalendarCompatible.

The date set by the dayOfMonth user.

 

Iv. Supplement

Sample Code

Public class DatePickerDialogSampleActivity extends Activity {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );

Final Calendar calendar = Calendar. getInstance ();
Final int year = calendar. get (Calendar. YEAR );
Final int month = calendar. get (Calendar. MONTH );
Final int day = calendar. get (Calendar. DAY_OF_MONTH );

Final DatePickerDialog datePickerDialog = new DatePickerDialog (
This,
New DatePickerDialog. OnDateSetListener (){
@ Override
Public void onDateSet (DatePicker view, int year, int monthOfYear, int dayOfMonth ){
Toast. makeText (DatePickerDialogSampleActivity. this,
String. valueOf (year) + "/" +
String. valueOf (monthOfYear + 1) + "/" +
String. valueOf (dayOfMonth ),
Toast. LENGTH_SHORT). show ();
}
},
Year, month, day );
DatePickerDialog. show ();
}
}

V. related chapters

Android Chinese API (20) -- DatePicker

 

 

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.