网上搜索了下没有找到DatePickerDialog的各种 Theme 的样例。我就一个一个试了下,传上图片

DatePickerDiaolog有两个构造函数分别是:

DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
DatePickerDialog(Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)

其中第一个构造函数没有指定theme就是用工程的默认theme下的DatePickerDialog把

第二个构造函数的第二个参数表示的就是DatePickerDialog的几种风格了。可以是以下常量:

对应的视图效果:

‘’

Demo:

对应生成一个DatePickerDialog的代码如下

Dialog dialog=new DatePickerDialog(
mContext,
DatePickerDialog.THEME_DEVICE_DEFAULT_DARK,
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {

}
   },
   1990,8,16);//表示默认的年月日

dialog.show();

添加  设置  取消按钮 (有些手机界面被定制了   没有取消按钮)

//添加确定按钮
            mDialog.setButton(DatePickerDialog.BUTTON_POSITIVE, 
                    mContext.getResources().getString(R.string.hint_ok), 
                    new DialogInterface.OnClickListener() {
                        
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub                            
                            flag = true;                           
                        }
                    });  
            //添加取消按钮
            mDialog.setButton(DatePickerDialog.BUTTON_NEGATIVE, 
                    mContext.getResources().getString(R.string.hint_cancel), 
                    new DialogInterface.OnClickListener() {
                        
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub                            
                            flag = false;                           
                        }
                    });

android DatePickerDialog theme的更多相关文章

  1. android 中theme样式的解释

    android:theme="@android:style/Theme.Dialog" : Activity显示为对话框模式 android:theme="@androi ...

  2. 解决android:theme="@android:style/Theme.NoDisplay" 加入这句话后程序不能运行

    原因: 原来用的是ActionBarActivity,继承自 ActionBarActivity的类必须指定固定的集中Theme风格,而这些 Theme 风格是需要导入V7中的 appcompat L ...

  3. Android主题theme和风格style总结

    用到了Android的主题和风格,感觉很多地方需要总结和记录下来.其实主题和风格是有很大的作用的,特别是界面要求比较高的客户端. Style:是一个包含一种或者多种格式化属性的集合,我们可以将其用为一 ...

  4. Android中theme.xml与style.xml的区别

    一.相同点 两者的定义相同.继承方式也相同 <?xml version="1.0" encoding="utf-8"?> <resources ...

  5. Android 主题theme说明 摘记

    主题Theme就是用来设置界面UI风格,可以设置整个应用或者某个活动Activity的界面风格.在Android SDK中内置了下面的Theme,可以按标题栏Title Bar和状态栏Status B ...

  6. Android studio使用android:style/Theme.Dialog报错:You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)

    查找原因是在activity java代码部分继承了compatactivity public class DialogActivity extends AppCompatActivity 但是在An ...

  7. Android 指定 Theme

    在 application 标签中添加 android:theme="@android:style/Theme.Holo.Light.NoActionBar"

  8. android 中theme.xml与style.xml的区别

    from://http://liangoogle.iteye.com/blog/1848448 android 中theme.xml与style.xml的区别: 相同点: 两者的定义相同. <r ...

  9. android应用Theme(二)

    另外一种实现android应用Theme的方式是通过apk来实现的. 以下是一个demo. 1.首先必须新建一个apk.类似的插件,然后在该apk的AndroidManifest.xml文件的appl ...

随机推荐

  1. mysql中select distinct的用法

    在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但 往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的 ...

  2. PHP中Global和Local范围以及Static变量

    1. Local scope function update_counter() { $counter++;//此处$counter为局部变量,与函数外的$counter非同一个 } $counter ...

  3. *循环-01. 求整数段和【help】

    /* * Main.c * 循环-01. 求整数段和 * Created on: 2014年6月18日 * Author: Boomkeeper ***测试木有通过**** */ #include & ...

  4. getopt vs getopts

    getopt示例 #!/bin/bash aflag=no args=`getopt a: $@` ]; then echo 'Usage: ...' exit fi set -- $args ] d ...

  5. Python学习笔记6-异常捕获取

    #--encoding:utf-8-- try: float('abc') except Exception,e: print e try: float(1.2) except Exception,e ...

  6. Struts 2.3.4.1完整示例

    [系统环境]Windows 7 Ultimate 64 Bit [开发环境]JDK1.6.21,Tomcat6.0.35,MyEclipse10 [其他环境]Struts2.3.4.1 [项目描述]S ...

  7. wx

    wx The classes in this module are the most commonly used classes for wxPython, which is why they hav ...

  8. C#.NET学习笔记1---C#.NET简介

    C#.NET学习笔记1---C#.NET简介 技术qq交流群:JavaDream:251572072  教程下载,在线交流:创梦IT社区:www.credream.com -------------- ...

  9. <memory> is not a BOMStorage file

    解决 Autoresizing 和AutoLayout 冲突 设置 self.autoresizingMask = UIViewAutoresizingNone;

  10. 查询SQL中某表里有多少列包含某字段

    select c.name from SYSCOLUMNS as c left join SYSOBJECTS as t on c.id=t.id where c.name like '这里是某个字段 ...