静态我的意思是,我有一些数据说20,其最大值可以是100.我想将其命名为Progress。然后我需要一个在打开Progress选项卡时调用的活动。加载进度的位置,当达到100的20时停止。
它应该最终看起来像。
Progress.
++++----------------
Progress1.
+++++++++++---------
Progress3.
+++++++-------------
我用Google搜索并获得了完全告诉我的要求的这个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链接一样。
答案 0 :(得分:1)
这是一个想法:
听起来怎么样?