当前位置:网站首页>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 " />



边栏推荐
- How to implement safety practice in software development stage
- Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
- Leetcode brush questions day49
- The top of slashdata developer tool is up to you!!!
- 【分布式理论】(一)分布式事务
- Mrs offline data analysis: process OBS data through Flink job
- 使用Stace排除故障的5种简单方法
- Establishment of solid development environment
- [Fantan] how to design a test platform?
- Nerf: the ultimate replacement for deepfake?
猜你喜欢

Biped robot controlled by Arduino

Sator launched Web3 game "satorspace" and launched hoobi

鲲鹏开发者峰会2022 | 麒麟信安携手鲲鹏共筑计算产业新生态

赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性

【解惑】App处于前台,Activity就不会被回收了?

【分布式理论】(二)分布式存储

Functions and usage of viewflipper

How to choose the appropriate automated testing tools?

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

企业即时通讯软件是什么?它有哪些优势呢?
随机推荐
LeetCode刷题day49
【TPM2.0原理及应用指南】 12、13、14章
Problems encountered in Jenkins' release of H5 developed by uniapp
Show progress bar above window
第2章搭建CRM项目开发环境(数据库设计)
Examen des lois et règlements sur la sécurité de l'information
The mail server is listed in the blacklist. How to unblock it quickly?
Solid function learning
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
Jenkins发布uniapp开发的H5遇到的问题
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
A tour of grpc:03 - proto serialization / deserialization
Flash build API Service - generate API documents
From Devops to mlops: how do it tools evolve to AI tools?
【TPM2.0原理及应用指南】 16、17、18章
责任链模式 - Unity
textSwitch文本切换器的功能和用法
【网络攻防原理与技术】第1章:绪论
麒麟信安携异构融合云金融信创解决方案亮相第十五届湖南地区金融科技交流会
【网络攻防原理与技术】第6章:特洛伊木马