AUDatePicker is a date selection control and is essentially a pop-up window.
Dependency
See Quick start.
API description
/**
* 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)
/**
* Set the date range.
*
* @param startYear the start year
* @param endYear the end year
*/
public void setRange(int startYear, int endYear)
··/**
* Select the specified year, month, and date.
*
* @param year the year
* @param month the month
* @param day the day
*/
public void setSelectedItem(int year, int month, int day)
/**
* Select the specified date.
*
* @param yearOrMonth the year or month
* @param monthOrDay the month or day
*/
public void setSelectedItem(int yearOrMonth, int monthOrDay)
/**
* Set the date selection listener.
*
* @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
No customized property is available. The XML layout file is not supported.
Sample code
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();
Application of AUDatePicker on a build-in 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 more information, please search for group number 41708565 with DingTalk to join DingTalk group to contact mPaaS after-sales support.