AUDatePicker is a date picker control that appears as a pop-up window.
API reference
/**
* Instantiates a new Date picker.
*
* @param activity the activity
* @param mode the mode
* @see #YEAR_MONTH_DAY #YEAR_MONTH_DAY#YEAR_MONTH_DAY
* @see #YEAR_MONTH #YEAR_MONTH#YEAR_MONTH
* @see #MONTH_DAY #MONTH_DAY#MONTH_DAY
*/
public AUDatePicker(Activity activity, @Mode int mode)
/**
* Sets the date range.
*
* @param startYear the start year
* @param endYear the end year
*/
public void setRange(int startYear, int endYear)
··/**
* Selects a specific year, month, and day.
*
* @param year the year
* @param month the month
* @param day the day
*/
public void setSelectedItem(int year, int month, int day)
/**
* Selects a specific date.
*
* @param yearOrMonth the year or month
* @param monthOrDay the month or day
*/
public void setSelectedItem(int yearOrMonth, int monthOrDay)
/**
* Sets the listener for date selection.
*
* @param listener the listener
*/
public void setOnDatePickListener(OnDatePickListener listener) {
this.onDatePickListener = listener;
}
/**
* The interface on year month day pick listener.
*/
public interface OnYearMonthDayPickListener extends OnDatePickListener {
/**
* On date picked.
*
* @param year the year
* @param month the month
* @param day the day
*/
void onDatePicked(String year, String month, String day);
}
/**
* The interface On year month pick listener.
*/
public interface OnYearMonthPickListener extends OnDatePickListener {
/**
* On date picked.
*
* @param year the year
* @param month the month
*/
void onDatePicked(String year, String month);
}
/**
* The interface On month day pick listener.
*/
public interface OnMonthDayPickListener extends OnDatePickListener {
/**
* On date picked.
*
* @param month the month
* @param day the day
*/
void onDatePicked(String month, String day);
}Custom properties
This control has no custom properties and does not support XML layout files.
Code examples
AUDatePicker datePicker = new AUDatePicker(DatePickActivity.this,AUDatePicker.YEAR_MONTH_DAY);
datePicker.setRange(1949,2050);
datePicker.setOnDatePickListener(new AUDatePicker.OnYearMonthDayPickListener() {
@Override
public void onDatePicked(String year, String month, String day) {
Toast.makeText(DatePickActivity.this,year + "-" + month + "-" + day,Toast.LENGTH_LONG).show();
}
});
datePicker.show();To use AUDatePicker on an embedded page:
AUDatePicker picker = new AUDatePicker(this);
picker.show();
picker.dismiss();
View view = picker.getOutterView();
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.removeAllViews();
if(view != null) {
((ViewGroup) view.getParent()).removeAllViews();
layout.addView(view);
}For assistance, join our DingTalk group by searching for group number 145930007362 and contact the helpdesk.