当前位置: 首页 > news >正文

德宏傣族景颇族自治州网站建设_网站建设公司_SEO优化_seo优化

做网站的价格贵吗,桂林网站建设哪家好,页面异常导致本地路径泄漏 wordpress,免费网站后台管理系统模板下载熟悉和掌握Android线程的使用 实验要求#xff1a; 完成一个秒表#xff0c;具备启停功能#xff0c;正确使用工作线程完成界面刷新 分析秒表的计时是否准确#xff0c;原因是什么#xff0c;如何保证秒表计时准确 代码实现#xff1a; #xff08;1#xff09;Activit…熟悉和掌握Android线程的使用 实验要求 完成一个秒表具备启停功能正确使用工作线程完成界面刷新 分析秒表的计时是否准确原因是什么如何保证秒表计时准确 代码实现 1Activity_main.xml ?xml version1.0 encodingutf-8? LinearLayoutxmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthfill_parentandroid:layout_heightwrap_contentandroid:orientationverticalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text秒表android:textSize30dpandroid:paddingTop80dp/LinearLayoutandroid:layout_widthfill_parentandroid:layout_heightwrap_contentandroid:gravitycenterTextViewandroid:idid/tv_minandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize25dpandroid:text00/TextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize25dpandroid:text:/TextViewandroid:idid/tv_secondsandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize25dpandroid:text00/TextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize25dpandroid:text:/TextViewandroid:idid/tv_msandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize25dpandroid:text00//LinearLayoutLinearLayoutandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentButtonandroid:idid/btn_cleanandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text清零android:textSize20dp/Buttonandroid:idid/btn_countandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text计时android:textSize20dp/Buttonandroid:idid/btn_stopandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text停止android:textSize20dp//LinearLayout /LinearLayout 2MainActivity.java文件 package com.example.administrator.myapplication5;import android.app.Activity; import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;public class MainActivity extends Activity {private static Handler handlernew Handler();private static TextView tv_minus;private static TextView tv_seconds;private static TextView tv_ms;public static int minuts;public static int seconds;public static int mseconds;Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);tv_minus(TextView)findViewById(R.id.tv_min);tv_seconds(TextView)findViewById(R.id.tv_seconds);tv_ms(TextView)findViewById(R.id.tv_ms);final Button btn_clean(Button)findViewById(R.id.btn_clean);final Button btn_count(Button)findViewById(R.id.btn_count);final Button btn_stop(Button)findViewById(R.id.btn_stop);final Intent serviceIntentnew Intent(this,CountService.class);btn_clean.setOnClickListener(new View.OnClickListener(){Overridepublic void onClick(View view){System.out.println(thisisatestsssss);tv_minus.setText(00);tv_seconds.setText(00);tv_ms.setText(00);}});btn_count.setOnClickListener(new View.OnClickListener(){Overridepublic void onClick(View view){startService(serviceIntent);//显示启动service}});btn_stop.setOnClickListener(new View.OnClickListener(){Overridepublic void onClick(View view){stopService(serviceIntent);//停止service}});}public static void UpdateGUI(int m,int s,int ms){minutsm;secondss;msecondsms;handler.post(RefreshLable);}static Runnable RefreshLablenew Runnable() {Overridepublic void run() {try {Thread.sleep(50);tv_minus.setText(String.format(%02d,minuts));tv_seconds.setText(String.format(%02d,seconds));tv_ms.setText(String.format(%02d,mseconds%100));} catch (InterruptedException e) {e.printStackTrace();}}}; } 3CountService.Java文件 package com.example.administrator.myapplication5;import android.app.Service; import android.content.Intent; //import android.icu.util.Calendar; import android.os.IBinder; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView;import java.util.Calendar;/*** Created by lh on 2018/10/22.*/public class CountService extends Service {private Thread workThread;long startTimeSystem.currentTimeMillis();Overridepublic void onCreate() {super.onCreate();workThreadnew Thread(null,backgroundThread,workThread);}Overridepublic void onStart(Intent intent,int startId) {super.onStart(intent,startId);if(!workThread.isAlive()){workThread.start();}} Overridepublic void onDestroy() {super.onDestroy();workThread.interrupt();}Overridepublic IBinder onBind(Intent intent){return null;}private Runnable backgroundThreadnew Runnable() {Overridepublic void run() {try{while(!Thread.interrupted()){long currentTimeSystem.currentTimeMillis();long timecurrentTime-startTime;long mtime/(1000*60);long stime/1000;long mstime%1000;int mi(int)m;int si(int)s;int msi(int)ms;MainActivity.UpdateGUI(mi,si,msi);workThread.sleep(50);}}catch (InterruptedException e){e.printStackTrace();}}}; } 4AndroidManifest.xml文件 ?xml version1.0 encodingutf-8? manifest xmlns:androidhttp://schemas.android.com/apk/res/androidpackagecom.example.administrator.myapplication5applicationandroid:allowBackuptrueandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:roundIconmipmap/ic_launcher_roundandroid:supportsRtltrueandroid:themestyle/AppThemeactivity android:name.MainActivityintent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter/activityservice android:name.CountService//application/manifest 总结 setText()括号内应该是String类型   System.currentTimeMillis()函数来获取系统时间    转载于:https://www.cnblogs.com/loyolh/p/9954572.html
http://www.lebaoying.cn/news/71369.html

相关文章:

  • 内蒙和城乡建设部网站山西太原今天的消息
  • 自己做网站的流程长春优化
  • 模板网站建设珠海网站开发费用摊销时间
  • 美术馆网站建设电子商务营销的发展现状
  • 图文型官网站wordpress 科技公司
  • 网站风格介绍wordpress seo什么意思
  • diy科技制作网站dt高端网站设计
  • 如何用模板建设网站国外网站排行榜
  • 中国微电影 网站开发者a站app
  • 本机怎么放自己做的网站用ps做网站方法
  • 网站开发成本预算单页面网站有哪些内容吗
  • 顺德顺的网站建设网站建设哪
  • 做dhl底单的网站是 什么网站排名突然下降解决
  • 临淄区住房和城乡建设局网站学做效果图网站有哪些软件有哪些
  • 中国摄影在线网站那些网站做的非常好看的
  • 网站设计需求分析报告网页设计实训报告不足
  • 公司网站建设前期方案中国it外包公司排名
  • 聊城网站制作信息余姚网络推广
  • 游戏网站开发找什么人可建东莞常平医院
  • 做外贸有效的网站凌天科技 wordpress
  • 福建省铁路建设办公室网站网站开发及app开发报价
  • 刷网站排名 优帮云新手建什么网站赚钱吗
  • 网站后台是怎么做出来的普通网站和营销型网站的区别是什么
  • 建设一个网站需要网上推广的平台有哪些
  • 房山新农村建设网站网站怎么做留言的
  • 西部数码网站管理助手4.0 教程类似于建设通的网站
  • 温江网站制作深圳搜索优化排名
  • 怎样在中国建设银行网站开通短信提醒网络营销的基本功能
  • 安徽建设工程网站外贸询单
  • 山西建设官方网站关键词排名工具有哪些