当前位置:网站首页>DatePickerDialog and trimepickerdialog
DatePickerDialog and trimepickerdialog
2022-07-07 17:37:00 【XLMN】
DatePickerDialog and trimepickerDialog
Set time dialog box and date dialog box
public class MainActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pickerdialog);
Button datebt = findViewById(R.id.datebt);
Button timebt = findViewById(R.id.timebt);
// Bind listeners for the set date button
datebt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar ca = Calendar.getInstance();
// Create a DatePickerDialog Dialog instance , And show him // Bind listener
new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
EditText show = findViewById(R.id.show);
show.setText(“ You chose :” + year + “ year ” + (month + 1) + “ month ” + dayOfMonth + “ Japan ”);
}
}
// Set the initial date
, ca.get(Calendar.YEAR),
ca.get(Calendar.MONTH),
ca.get(Calendar.DAY_OF_MONTH)).show();
}
});
// Set the listener for the set time button
timebt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar ca1 = Calendar.getInstance();
// Create a TimePickerDialog Instance and display it
new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
EditText et = findViewById(R.id.show);
et.setText(" You chose :" + hourOfDay + " when " + minute + " branch ");
}
}
// Set initial time
, ca1.get(Calendar.HOUR_OF_DAY),
ca1.get(Calendar.MINUTE), true
//true use 24 hourly
).show();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?><EditText
android:id="@+id/show"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/datebt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Date selection dialog " />
<Button
android:id="@+id/timebt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Time selection dialog " />



边栏推荐
- 第2章搭建CRM项目开发环境(数据库设计)
- Sator推出Web3游戏“Satorspace” ,并上线Huobi
- 【TPM2.0原理及应用指南】 9、10、11章
- Leetcode brush questions day49
- TabHOST 选项卡的功能和用法
- 百度地图自定义样式向右拖拽导致全球地图经度0度无法正常显示
- A tour of grpc:03 - proto serialization / deserialization
- L1-028 判断素数(Lua)
- 麒麟信安携异构融合云金融信创解决方案亮相第十五届湖南地区金融科技交流会
- Sator launched Web3 game "satorspace" and launched hoobi
猜你喜欢

textSwitch文本切换器的功能和用法

Sator推出Web3游戏“Satorspace” ,并上线Huobi

datepicket和timepicket,日期、时间选择器的功能和用法

Mrs offline data analysis: process OBS data through Flink job

【网络攻防原理与技术】第1章:绪论

TabHOST 选项卡的功能和用法

Matplotlib绘制三维图形

PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight

Matplotlib绘图界面设置

redis主从、哨兵主备切换搭建一步一步图解实现
随机推荐
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
Functions and usage of ratingbar
textSwitch文本切换器的功能和用法
Function and usage of textswitch text switcher
让保险更“保险”!麒麟信安一云多芯云桌面中标中国人寿, 助力金融保险信息技术创新发展
notification是显示在手机状态栏的通知
A tour of grpc:03 - proto serialization / deserialization
【可信计算】第十二次课:TPM授权与会话
管理VDI的几个最佳实践
DNS 系列(一):为什么更新了 DNS 记录不生效?
Several best practices for managing VDI
What is cloud computing?
Dateticket and timeticket, functions and usage of date and time selectors
使用 xml资源文件定义菜单
Sator launched Web3 game "satorspace" and launched hoobi
Repair method of firewall system crash and file loss, material cost 0 yuan
第二十四届中国科协湖南组委会调研课题组一行莅临麒麟信安调研考察
ViewSwitcher的功能和用法
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
Establishment of solid development environment