EasyDemo*DatePicker(on Github)
来源:互联网 发布:矩阵与转置矩阵的秩 编辑:程序博客网 时间:2024/06/03 20:53
DatePicker()
开发环境:Eclipse
开发环境:Eclipse
点击打开链接
直接上代码。。。
package com.example.datetimepickerdemo;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.DatePicker;
import android.widget.TextView;
public class DatePickerDemo extends Activity {
static int mYear, mMonth, mDay;
private TextView tv_singed_date, tv_expire_date;
final int SINGED_DATE_DIALOG = 1;
final int EXPIRE_DATE_DIALOG = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_singed_date = (TextView) findViewById(R.id.tv_singed_date);
tv_expire_date = (TextView) findViewById(R.id.tv_expire_date);
tv_singed_date.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
showDialog(SINGED_DATE_DIALOG);
}
});
tv_expire_date.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
showDialog(EXPIRE_DATE_DIALOG);
}
});
final Calendar ca = Calendar.getInstance();
mYear = ca.get(Calendar.YEAR);
mMonth = ca.get(Calendar.MONTH);
mDay = ca.get(Calendar.DAY_OF_MONTH);
}
@Override
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
switch (id) {
case SINGED_DATE_DIALOG:
return new DatePickerDialog(this, singed_mdateListener, mYear,
mMonth, mDay);
case EXPIRE_DATE_DIALOG:
return new DatePickerDialog(this, expire_mdateListener, mYear,
mMonth, mDay);
}
return null;
}
// 设置文本的内容 -宋玮琦 2017-11-15
public void singed_date_display() {
tv_singed_date.setText(new StringBuffer().append(mYear).append("-")
.append(mMonth + 1).append("-").append(mDay).append(""));
}
public void expire_date_display() {
tv_expire_date.setText(new StringBuffer().append(mYear).append("-")
.append(mMonth + 1).append("-").append(mDay).append(""));
}
private DatePickerDialog.OnDateSetListener singed_mdateListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
singed_date_display();
}
};
private DatePickerDialog.OnDateSetListener expire_mdateListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
expire_date_display();
}
};
}
阅读全文
0 0
- EasyDemo*DatePicker(on Github)
- EasyDemo*TextWatcher(on Github)
- EasyDemo*PopupWindow(on Github)
- EasyDemo*FrameAnimation(on Github)
- EasyDemo*VideoView(on Github)
- EasyDemo*AlertDialog对话框(on Github)
- EasyDemo*Fragment静态使用方法(on Github)
- EasyDemo*JavaSE 细节知识点(Updating on Github)
- EasyDemo*Menu体系结构图(on Github)
- EasyDemo*Dialog体系结构图(on Github)
- EasyDemo*ProgressBar及其子类体系结构图(on Github)
- EasyDemo*TextView及其子类体系结构图(on Github)
- EasyDemo*ViewAnimator及其子类体系结构图(on Github)
- EasyDemo*ExpandableListView及其子类体系结构图(on Github)
- EasyDemo*Adapter接口及其实现类体系结构图(on Github)
- EasyDemo*五大布局体系结构图(on Github)
- EasyDemo* ImageView及其子类体系结构图(on Github)
- EasyDemo*AdapterView及其子类体系结构图(on Github)
- EasyDemo*FrameAnimation(on Github)
- python2和python3共存(原生)
- EasyDemo*VideoView(on Github)
- Retrofit简单使用
- Spark入门1-使用Spark-shell交互分析
- EasyDemo*DatePicker(on Github)
- 《大型网站系统与JAVA中间件实践》【PDF】下载
- 《七点三刻》025期 乌镇时间/八项规定表情包发布/西成高铁开通/互联网大佬…
- Semaphore / 信号计数量[Version-2] / Sema的工作原理
- 可视化
- 网络获取+动画
- 网络判断+数据拼接
- Rxjava
- GPS修改,定位修改,GPS修改器,模拟GPS,虚假定位