0
通过静态我的意思是,我有一些数据说20,其最大值可以是100.我想命名它的进展。然后我需要一个活动,当我们打开进度选项卡时会被调用。它加载进度并在达到20时停止。在Android中创建静态进度条
它最终应该看起来像。
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和进度
我想说明多个进度条,动画只是里在上面的GIF链接中。
我做到了。它的工作。 :D谢谢! – impossible
@ArewegoodQ真棒,很棒的工作! – iheanyi