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

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

工作实录之《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. 对接HiveMetaStore,拥抱开源大数据

    本文分享自华为云社区<对接HiveMetaStore,拥抱开源大数据>,作者:睡觉是大事. 1. 前言 适用版本:9.1.0及以上 在大数据融合分析时代,面对海量的数据以及各种复杂的查询, ...

  2. 如何合理使用 CPU 管理策略,提升容器性能?

    ​简介:CPU Burst.拓扑感知调度是阿里云容器服务 ACK 提升应用性能的两大利器,它们解决了不同场景下的 CPU 资源管理,可以共同使用.点击下文,查看详情! 作者:张佐玮(佑祎) 前言 在云 ...

  3. 基于MaxCompute分布式Python能力的大规模数据科学分析

    ​简介: 如何利用云上分布式 Python 加速数据科学. 如果你熟悉 numpy.pandas 或者 sklearn 这样的数据科学技术栈,同时又受限于平台的计算性能无法处理,本文介绍的 MaxCo ...

  4. Java的Stream流的分页,Stream的skip和limit实现分页

    1.工具类 package com.cc.testproject.utils; import com.github.pagehelper.PageInfo; import org.springfram ...

  5. 01二分 [AGC006D] Median Pyramid Hard + P2824 [HEOI2016/TJOI2016] 排序

    [AGC006D] Median Pyramid Hard 考虑对于一个长度为 2n + 1 的 01 序列 b 如何快速确定堆顶元素. _ _ _ _ x _ _ _ 0 x _ _ 0 0 x _ ...

  6. 引爆你的网页乐趣!前端十个令人捧腹的JavaScript整蛊代码。

    愚人节整蛊代码.想要在网页上增添一抹幽默与惊喜吗?或是想给你的朋友一个意想不到的"小惊喜"?那么,这十款简单而有趣的JavaScript前端整蛊代码绝对能满足你的需求!每一个代码都 ...

  7. 【图形数据集】CIFAR-10 dataset数据集

    文献引用:https://www.cs.toronto.edu/~kriz/cifar.html The CIFAR-10 dataset The CIFAR-10 dataset consists ...

  8. ITSM2023年十大功能趋势[采和]

    总体描述:更加人性化,引入自动化相关的设计和技术,更加实用好用.1. 100%服务目录服务目录必须完全贴合用户方的运维实际开展的 服务清单,而不是想当然的抄书或者臆想!都2023年了,还有完全不着调的 ...

  9. vue3.0 yarn启动项目

    linux 系统 在root账号下 yarn install yarn run serve 启动服务 ctrl+c //暂停服务 yarn build 打包服务 在公共目录里添加配置文件 优点:这样就 ...

  10. WEB服务与NGINX(26)- 实现Nginx高并发系统内核参数优化

    1. 实现Nginx高并发系统内核参数优化 由于默认的Linux内核参数考虑的是最通用场景,这明显不符合用于支持高并发访问的Web服务器的定义,所以需要修改Linux内核参数,使得Nginx可以拥有更 ...