(小米手机) (中兴手机)

在上一篇中,我介绍了一般公司都会自定义时间日期选择器,并结合自己所做的项目给大家参考。

工作实录之《Android开发卷——自定义日期选择器(一)》链接:http://blog.csdn.net/chillax_li/article/details/19047913

这里,我在之前的基础上做了修改,弄成对话框形式,更神似于Google提供的日期选择器API,项目部署跟上一篇是一样的。

自定义对话框类

public class TestDialog extends Dialog{

	private Context context;
private int style; public TestDialog(Context context) {
super(context);
this.context = context;
} public TestDialog(Context context,int style) {
super(context);
this.context = context;
this.style = style;
} @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.dialog); NumberPicker np1 = (NumberPicker) findViewById(R.id.np1);
NumberPicker np2 = (NumberPicker) findViewById(R.id.np2);
NumberPicker np3 = (NumberPicker) findViewById(R.id.np3); np1.setMaxValue(2999);
np1.setMinValue(1000);
np1.setValue(1999); np2.setMaxValue(12);
np2.setMinValue(1); np3.setMaxValue(31);
np3.setMinValue(1);
} @Override
public void show() {
// TODO Auto-generated method stub
super.show();
}
}

自定义对话框布局

<LinearLayout
android:id="@+id/dialog_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:paddingLeft="3dp" > <NumberPicker
android:id="@+id/np1"
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="20dp"
android:text="年"/>
<NumberPicker
android:id="@+id/np2"
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="20dp"
android:text="月"/>
<NumberPicker
android:id="@+id/np3"
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="20dp"
android:text="日"/>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1" />
<Button
android:id="@+id/dialog_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#00000000"
android:text="确定" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4" />
<Button
android:id="@+id/dialog_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#00000000"
android:text="取消" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1" />
</LinearLayout>

当然,项目中也还有存在不足,两个按钮的单击事件,本人在这里偷懒了,没有添加上去。大家可以自己添加上去,完善它。

详见《Android开发卷——自定义日期选择器(三)》:http://blog.csdn.net/chillax_li/article/details/19212895

下面链出项目源码地址:http://download.csdn.net/detail/chillax_li/6920631

尊重原创,转载请注明出处:http://blog.csdn.net/chillax_li/article/details/19172899

《Android开发卷——自定义日期选择器(二)》的更多相关文章

  1. 简单物联网:外网访问内网路由器下树莓派Flask服务器

    最近做一个小东西,大概过程就是想在教室,宿舍控制实验室的一些设备. 已经在树莓上搭了一个轻量的flask服务器,在实验室的路由器下,任何设备都是可以访问的:但是有一些限制条件,比如我想在宿舍控制我种花 ...

  2. 利用ssh反向代理以及autossh实现从外网连接内网服务器

    前言 最近遇到这样一个问题,我在实验室架设了一台服务器,给师弟或者小伙伴练习Linux用,然后平时在实验室这边直接连接是没有问题的,都是内网嘛.但是回到宿舍问题出来了,使用校园网的童鞋还是能连接上,使 ...

  3. 外网访问内网Docker容器

    外网访问内网Docker容器 本地安装了Docker容器,只能在局域网内访问,怎样从外网也能访问本地Docker容器? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Docker容器 ...

  4. 外网访问内网SpringBoot

    外网访问内网SpringBoot 本地安装了SpringBoot,只能在局域网内访问,怎样从外网也能访问本地SpringBoot? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装Java 1 ...

  5. 外网访问内网Elasticsearch WEB

    外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...

  6. 怎样从外网访问内网Rails

    外网访问内网Rails 本地安装了Rails,只能在局域网内访问,怎样从外网也能访问本地Rails? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Rails 默认安装的Rails端口 ...

  7. 怎样从外网访问内网Memcached数据库

    外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装 ...

  8. 怎样从外网访问内网CouchDB数据库

    外网访问内网CouchDB数据库 本地安装了CouchDB数据库,只能在局域网内访问,怎样从外网也能访问本地CouchDB数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Cou ...

  9. 怎样从外网访问内网DB2数据库

    外网访问内网DB2数据库 本地安装了DB2数据库,只能在局域网内访问,怎样从外网也能访问本地DB2数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动DB2数据库 默认安装的DB2 ...

  10. 怎样从外网访问内网OpenLDAP数据库

    外网访问内网OpenLDAP数据库 本地安装了OpenLDAP数据库,只能在局域网内访问,怎样从外网也能访问本地OpenLDAP数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动 ...

随机推荐

  1. 双11特刊|一站式在线数据管理平台DMS技术再升级,高效护航双11

    ​简介: 10万+企业共同选择的数据库服务平台 阿里云数据库已连续多年稳定支撑天猫双11,历经极端流量场景淬炼.除了保障稳定顺滑的基本盘,今年大促期间数据库通过全面云原生化,大幅提升用户体验,让技术帮 ...

  2. [Linux] 启动管理: 运行级别

    Link:https://www.cnblogs.com/farwish/p/14983932.html

  3. 使用 DISM 安全清理 C 盘 WinSxS 文件夹空间

    本文将介绍如何使用系统内置 DISM 工具进行安全清理 C 盘空间,清理 WinSxS 文件夹里面的可回收删除的程序包空间 开始之前,先使用管理员权限打开 CMD 或 PowerShell 命令行窗口 ...

  4. WPF 已知问题 dotnet 6 设置 InvariantGlobalization 之后将丢失默认绑定转换导致 XAML 抛出异常

    在设置了 InvariantGlobalization 为 true 之后,将会发现原本能正常工作的 XAML 可能就会抛出异常.本文将告诉大家此问题的原因 这是有开发者在 WPF 仓库上给我报告的 ...

  5. vue项目上线前优化(路由懒加载的使用,外部CDN的使用)

    引 当使用vue做完项目后,接下来当然是要进行线上部署了.但是在上线之前还是可以做很多方面优化的,可以让项目上线后的体验更加哦. 若是使用了vue-cli的话,可以从面板界面直观的看到各项数据,控制台 ...

  6. VGA显示文字

    VGA显示文字 VGA字符显示的原理 把要显示的字符转换成字符点阵,然后编码存储,着色的部分为1,其它为0.然后在VGA上输出显示. 字符点阵生成软件: https://www.zhetao.com/ ...

  7. Codeforces Round 940 (Div. 2) and CodeCraft-23 (A-E)

    A. Stickogon 题意:给定 \(n\) 根木棒长度,问最多构成几个多边形. 贪心,四边形不会优于三角形. submission B. A BIT of a Construction 题意:构 ...

  8. deepin下的系统,如何为root用户添加密码

  9. JDK源码阅读-------自学笔记(十三)(java.text.DateFormat和SimpleDateFormat类)

    时间相关类总图

  10. 10-flask博客项目

    centos7 编译安装python3.7.1 安装步骤 centos7自带python2,由于执行yum需要python2,所以即使安装了python3也不能删除python21.安装依赖包yum ...