Learn android from scratch (date selector: DatePicker usage. 12 .)

Source: Internet
Author: User
Tags date1

Another date selector (DatePicker) corresponding to the time selector can be used to set the year, month, and day. This class is defined as follows: java. lang. Object? Android. view. View? Android. view. ViewGroup? Android. widget. FrameLayout? Android. widget. DatePicker
Common Methods:

No. Method Type Description
1 Public int getYear () Normal Get the set year
2 Public int getMonth () Normal Get the set month
3 Public int getDayOfMonth () Normal Get set date
4 Public void setEnabled (boolean enabled) Normal Set whether the component is available
5 Public void updateDate (int year, int monthOfYear, int dayOfMonth) Normal Set a specified date

.................................................................. Beautiful cut line ..................................................................

   
  
 
JAVA file configuration
package com.example.datepicker11;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.widget.DatePicker;public class MainActivity extends Activity {private  DatePicker date=null;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        super. setContentView(R.layout.activity_main);    this.date=(DatePicker)super.findViewById(R.id.date2);    this.date.updateDate(1992, 03, 18);    }   }

You can change the simulator language to achieve the Chinese effect.

Next prediction: linearlayout linear Layout

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.