Android - DatePicker 樣式
Android - DatePicker 樣式
http://android--code.blogspot.tw/2015/08/android-datepickerdialog-theme.html
今天要做DatePicker,
但DatePicker其實有不少樣式,
但網路文章剛好有這個比較文章,可以操作試試。
public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
final Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
/*
Create a DatePickerDialog using Theme.
DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener listener,
int year, int monthOfYear, int dayOfMonth)
*/
// DatePickerDialog THEME_DEVICE_DEFAULT_LIGHT
DatePickerDialog dpd = new DatePickerDialog(getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT,this,year,month,day);
// DatePickerDialog THEME_DEVICE_DEFAULT_DARK
DatePickerDialog dpd2 = new DatePickerDialog(getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_DARK,this,year,month,day);
// DatePickerDialog THEME_HOLO_LIGHT
DatePickerDialog dpd3 = new DatePickerDialog(getActivity(),
AlertDialog.THEME_HOLO_LIGHT,this,year,month,day);
// DatePickerDialog THEME_HOLO_DARK
DatePickerDialog dpd4 = new DatePickerDialog(getActivity(),
AlertDialog.THEME_HOLO_DARK,this,year,month,day);
// DatePickerDialog THEME_TRADITIONAL
DatePickerDialog dpd5 = new DatePickerDialog(getActivity(),
AlertDialog.THEME_TRADITIONAL,this,year,month,day);
// Return the DatePickerDialog
return dpd;
}
public void onDateSet(DatePicker view, int year, int month, int day){
// Do something with the chosen date
}
}