首页 > 代码库 > ProgressBar
ProgressBar
package com.example.myprogressbar;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.ProgressBar;public class MainActivity extends Activity { ProgressBar progressBar1 ; /*long startTime =TimeUtil.timeToLong("2014-8-8 00:05:00")/1000; long endTime =TimeUtil.timeToLong("2014-8-8 00:06:00")/1000;*/ Thread thread; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressBar1 = (ProgressBar) findViewById(R.id.progressBar1); progressBar1.setProgress(0); Log.d("hefen", "time =="); thread =new Thread(new Runnable() { long currentTime = System.currentTimeMillis()/1000; @Override public void run() { int progressBarMax =100; while(progressBarMax!= progressBar1.getProgress()){ int stepProgress = 0; int currentProgress = progressBar1.getProgress(); stepProgress++; int currentTime = 100; int startTime =200; if(currentTime<=200){ currentTime+=10; } progressBar1.setProgress(currentProgress+stepProgress); Log.d("hefen", currentProgress+stepProgress+""); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } progressBar1.setProgress(0); } }); thread.start(); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); thread.stop(); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。