Reputation: 2500
By static I mean, I have some data say 20, whose max value can be 100. I want to name it Progress. Then I need an activity which will be called when we open Progress tab. Where it loads the Progress and stops when it reaches 20 out of 100.
It should finally look like.
Progress.
++++----------------
Progress1.
+++++++++++---------
Progress3.
+++++++-------------
I googled and got this gif which exactly tells my requirement. GIF
What I tried and could achieve is:
activity
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();
}
}
layout
It has a TextView, and a ProgressBar
I want to show multiple progress bar with the animation just like in the GIF link above.
Upvotes: 0
Views: 1185
Reputation: 3113
Here's an idea:
How does that sound?
Upvotes: 1