【发布时间】:2016-07-05 14:50:01
【问题描述】:
静态我的意思是,我有一些数据说 20,其最大值可以是 100。我想将其命名为进度。然后我需要一个活动,当我们打开进度选项卡时将调用它。它加载进度并在达到 100 分中的 20 分时停止。
它最终应该看起来像。
Progress.
++++----------------
Progress1.
+++++++++++---------
Progress3.
+++++++-------------
我用谷歌搜索并得到了这个 完全 告诉我的要求的 gif。 GIF
我尝试并可以实现的是:
活动
public class test extends Activity {
private ProgressBar progressBar;
private int progressStatus = 0, CurrValue=20;
private TextView textView;
private Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loop);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
textView = (TextView) findViewById(R.id.textView1);
progressBar.setScaleY(3f);
// Start long running operation in a background thread
Progress();
}
public void Progress(){
new Thread(new Runnable() {
public void run() {
while (progressStatus < CurrValue) {
progressStatus += 1;
// Update the progress bar and display the
//current value in the text view
handler.post(new Runnable() {
public void run() {
progressBar.setProgress(progressStatus);
textView.setText(progressStatus+"/"+progressBar.getMax());
}
});
try {
// Sleep for 200 milliseconds.
//Just to display the progress slowly
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
}
布局
它有一个TextView和一个ProgressBar
我想用动画显示多个进度条,就像上面的 GIF 链接一样。
【问题讨论】:
标签: android android-progressbar