如何实现DatePickerDialog自定义样式并全面掌握其使用方法?
- 内容介绍
- 文章标签
- 相关推荐
本文共计473个文字,预计阅读时间需要2分钟。
1. 设置主题为主界面主题 + new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT, null).show(); 效果:仅4.0及以上版本可用此主题,请注意版本判断。 如低版本设置主题,可使用:android:theme=@android:style/Theme
1.增加Theme主题
new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT,null).show();
效果:
4.0以上的版本才可使用此Theme,注意对版本的判断。
若低版本的则主题设置为以下
android:theme=”@android:style/Theme.Light.NoTitleBar”
效果:
2.新建DatePickerDialog
DatePickerDialog datePicker = new DatePickerDialog(MainActivity.this, AlertDialog.THEME_HOLO_LIGHT, new OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub } }, 2014, 1, 7); datePicker.show();
以上代码中设置了默认的日期为2014年1月7日。
本文共计473个文字,预计阅读时间需要2分钟。
1. 设置主题为主界面主题 + new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT, null).show(); 效果:仅4.0及以上版本可用此主题,请注意版本判断。 如低版本设置主题,可使用:android:theme=@android:style/Theme
1.增加Theme主题
new DatePickerDialog(this, AlertDialog.THEME_HOLO_LIGHT,null).show();
效果:
4.0以上的版本才可使用此Theme,注意对版本的判断。
若低版本的则主题设置为以下
android:theme=”@android:style/Theme.Light.NoTitleBar”
效果:
2.新建DatePickerDialog
DatePickerDialog datePicker = new DatePickerDialog(MainActivity.this, AlertDialog.THEME_HOLO_LIGHT, new OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) { // TODO Auto-generated method stub } }, 2014, 1, 7); datePicker.show();
以上代码中设置了默认的日期为2014年1月7日。

