《Android开发卷——自定义日期选择器(二)》
(小米手机)
(中兴手机)
在上一篇中,我介绍了一般公司都会自定义时间日期选择器,并结合自己所做的项目给大家参考。
工作实录之《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开发卷——自定义日期选择器(二)》的更多相关文章
- 简单物联网:外网访问内网路由器下树莓派Flask服务器
最近做一个小东西,大概过程就是想在教室,宿舍控制实验室的一些设备. 已经在树莓上搭了一个轻量的flask服务器,在实验室的路由器下,任何设备都是可以访问的:但是有一些限制条件,比如我想在宿舍控制我种花 ...
- 利用ssh反向代理以及autossh实现从外网连接内网服务器
前言 最近遇到这样一个问题,我在实验室架设了一台服务器,给师弟或者小伙伴练习Linux用,然后平时在实验室这边直接连接是没有问题的,都是内网嘛.但是回到宿舍问题出来了,使用校园网的童鞋还是能连接上,使 ...
- 外网访问内网Docker容器
外网访问内网Docker容器 本地安装了Docker容器,只能在局域网内访问,怎样从外网也能访问本地Docker容器? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Docker容器 ...
- 外网访问内网SpringBoot
外网访问内网SpringBoot 本地安装了SpringBoot,只能在局域网内访问,怎样从外网也能访问本地SpringBoot? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装Java 1 ...
- 外网访问内网Elasticsearch WEB
外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...
- 怎样从外网访问内网Rails
外网访问内网Rails 本地安装了Rails,只能在局域网内访问,怎样从外网也能访问本地Rails? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Rails 默认安装的Rails端口 ...
- 怎样从外网访问内网Memcached数据库
外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装 ...
- 怎样从外网访问内网CouchDB数据库
外网访问内网CouchDB数据库 本地安装了CouchDB数据库,只能在局域网内访问,怎样从外网也能访问本地CouchDB数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Cou ...
- 怎样从外网访问内网DB2数据库
外网访问内网DB2数据库 本地安装了DB2数据库,只能在局域网内访问,怎样从外网也能访问本地DB2数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动DB2数据库 默认安装的DB2 ...
- 怎样从外网访问内网OpenLDAP数据库
外网访问内网OpenLDAP数据库 本地安装了OpenLDAP数据库,只能在局域网内访问,怎样从外网也能访问本地OpenLDAP数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动 ...
随机推荐
- 技术干货 | 深度解构 Android 应用面临紧急发版时的救星方案:mPaaS 热修复——DexPatch
简介: 关于 Android 热修复方案--DexPatch 的介绍与使用说明 方案介绍 为了解决 Native 模块上线后的问题,mPaaS 提供了热修复功能,实现不发布客户端 apk 场景下的热修 ...
- 一年增加 1.2w 星,Dapr 能否引领云原生中间件的未来?
简介: 虽然 Dapr 在国外有很高的关注度,但在国内知名度非常低,而且现有的少量 Dapr 资料也偏新闻资讯和简单介绍,缺乏对 Dapr 的深度解读.在 Dapr v1.0 发布之际,我希望可以通过 ...
- [FAQ] Mac Mini 怎么让主机不休眠
Mac Mini 的防止休眠设置,在首选项,显示器里. 显示器里找到高级按钮. 然后有个开关是:显示器关闭时,防止自动进入睡眠.打开这个开关即可防止自动睡眠. Link:https://www.cnb ...
- dotnet 警惕 C# 的 is var 写法
本文将和大家介绍 C# 语言设计里面,我认为比较坑的一个语法.通过 is var 的写法,会让开发者误以为 null 是不被包含的,然而事实是在这里的 var 是被赋予含义的,将被允许 null 通过 ...
- VisualStudio 调试时会不断刷新 WPF 应用渲染
在 VisualStudio 附加调试和没有用 VisualStudio 附加调试时,对应用程序是有不同的影响,如 VisualStudio 设计器将会在附加调试 WPF 应用的时候,不断刷新 WPF ...
- vue-公共组件的注册
注册公共组件,在每个需要的页面直接输入文件名(<g-table/>)即可引用该组件 步骤: 1.新建components/global文件夹,以及components/global/g-t ...
- vue项目hbuilder打包-微信登录调取手机微信登录权限
这个笔记得做好. 1.vue页面的点击事件 import {login,loginy,wxLog,wxLogin,logout} from '../network/login' wxloginBtn( ...
- 16、数据库加固-mysql 加固
1.修改 DBA 登录密码 shell 下执行: mysqladmin -u root password 非首次修改:mysqladmin -u root password -p原密码 在 mysql ...
- Maven - cmd命令行窗口创建maven项目
一.构建命令 mvn archetype:generate 当出现以上的命令提示,直接回车下一步即可: 二.输入maven项目的groupId.artifactId.version 三.maven项目 ...
- 4G EPS 的架构模型
目录 文章目录 目录 前文列表 EPS 的架构 EPS 的架构模型 E-UTRAN UE eNodeB EPC MME(移动性管理) SGW(本地移动性锚点) PGW(业务锚点) HSS(用户认证及鉴 ...