清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
我们在做APP开发的时候,有时候需要写一个类似于电子表时间的内容,来显示当前时间,不多说,上代码: ``` private static final int MSG_TIME = 1; private TextView tv_time_nor; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_TIME: tv_time_nor.setText(getDate()); break; } } }; Runnable timeRunnable = new Runnable() { @Override public void run() { do { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } handler.sendEmptyMessage(MSG_TIME); }while(true); } }; Thread thread = new Thread(timeRunnable); thread.start(); //使用的时候,开启线程即可 //获取某天在一周的第几天,注意,在英语环境里,Sunday是一周第一天 Calender calender = Calender.getInstance(); String numOfWeek = calender.get(Calender.DAY_OF_WEEK);