当我运行程序时,系统当前时间显示在文本视图中。现在我有一个按钮、一个edittext 和一个textview。我想当我在edittext上放40时,我按当前小时秒数计算,然后通过在textview上按下按钮来显示它。当我从edittext中获取它时,我只想计算当前的小时秒数。如您所知,当当前小时秒数以数字计算时,它也会影响分钟和小时
帮我请这个代码显示当前时间:
Thread myThread = null;
Runnable runnable = new CountDownRunner();
myThread= new Thread(runnable);
myThread.start();
}
public void doWork() {
runOnUiThread(new Runnable() {
public void run() {
try{
txtCurrentTime= (TextView)findViewById(R.id.lbltime);
Date dt = new Date();
int hours = dt.getHours();
int minutes = dt.getMinutes();
int seconds = dt.getSeconds();
String curTime = hours + ":" + minutes + ":" + seconds;
txtCurrentTime.setText(curTime);