苏州大学Android[韩冬]期末复习(4)

2020-05-01 11:54

txt.setText(format.format(oldtime)); }

else if(msg.what==0x456) {

thread.stop(); } } };

Runnable runnable=new Runnable() { @Override public void run() { while(isstop) { try {

Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); }

Date newtime=new Date(oldtime.getTime()+1000); oldtime=newtime;

handler.sendEmptyMessage(0x123); }

} };

@Override

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnstart=(Button)findViewById(R.id.btnstart); btnend=(Button)findViewById(R.id.btnend); txt=(TextView)findViewById(R.id.txttime); oldtime=new Date(); oldtime.setHours(0); oldtime.setMinutes(0); oldtime.setSeconds(0);

btnstart.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(View arg0) { isstop=true; if(thread==null){

thread=new Thread(runnable); thread.start(); } }

});

btnend.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(View arg0) { isstop=false; }); } }

if(thread!=null){ thread.interrupt(); thread=null; } }


苏州大学Android[韩冬]期末复习(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:结题报告 课程理念下教师教学方式和学生学习方式转变的结题报告

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: