android 地址 日期选择器
package com.demo.dtselector; import com.custom.dtselector.dialog.DateSelectorDialog; import com.custom.dtselector.dialog.DateSelectorDialog.OnSelectDateEvent; import com.custom.dtselector.dialog.TimeSelectorDialog; import com.custom.dtselector.dialog.TimeSelectorDialog.OnSelectTimeEvent; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class DateTimeSelectorActivity extends Activity { private Activity activity = null; private DateSelectorDialog dateDialog = null; private TimeSelectorDialog timeDialog = null; private TextView txt_date_show = null; private TextView txt_time_show = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.datetime_main); activity = this; Button btnDate = (Button)findViewById(R.id.btn_date_selector); btnDate.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDateDialog(); } }); Button btnTime = (Button)findViewById(R.id.btn_time_selector); btnTime.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub showTimeDialog(); } }); txt_date_show = (TextView)findViewById(R.id.txt_date_show); txt_time_show = (TextView)findViewById(R.id.txt_time_show); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.datetime_selector, menu); return true; } private void showDateDialog() { if (dateDialog == null) { dateDialog = new DateSelectorDialog(); dateDialog.init(activity); dateDialog.setOnSelectDateEvent(new OnSelectDateEvent(){ @Override public void onSelectDateResult(int year, int month, int day) { // TODO Auto-generated method stub txt_date_show.setText(String.format("d-d-d", year,month,day)); } }); } dateDialog.show(); } private void showTimeDialog() { if (timeDialog == null) { timeDialog = new TimeSelectorDialog(); timeDialog.init(activity); timeDialog.setOnSelectTimeEvent(new OnSelectTimeEvent(){ @Override public void onSelectTimeResult(int hour, int minute, int second) { // TODO Auto-generated method stub txt_time_show.setText(String.format("d:d:d", hour,minute,second)); } }); } else { timeDialog.update(null); } timeDialog.show(); } }
- 1
- qq_281118252015-08-16虽然不是我想要的效果 学习了
- 粉丝: 238
- 资源: 17
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- java毕业设计-网上订餐系统源码+数据库.zip
- 基于双闭环PID控制的一阶倒立摆simscape建模matlab源码.zip
- 基于51单片机+lcd12864显示俄罗斯方块小游戏MCU软件源代码.zip
- 基于单片机的智能计算器设计MCU软件源代码.zip
- 基于Javaweb的药店管理系统源码+数据库.zip
- (自适应手机端)网络建站广告公司网站pbootcms模板 品牌策划设计类网站源码下载.zip
- (自适应手机端)手机软件APP下载类网站Pbootcms模板 游戏软件应用网站源码下载.zip
- (自适应手机端)生活百科资讯文章博客类网站pbootcms模板 绿色新闻博客网站源码下载.zip
- 基于OpenCV+MySQL+QT实现的人脸识别考勤系统源码.zip
- java毕业设计网上订餐系统源码+数据库.zip