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