Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button button = (Button) findViewById(R.id.button);
- final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- progressBar.setProgress(1);
- new Thread(new Runnable() {
- @Override
- public void run() {
- for (int i = 1; i <= 100; i++) {
- final int progress = i;
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- progressBar.post(new Runnable() {
- @Override
- public void run() {
- progressBar.setProgress(progress);
- }
- });
- }
- }
- }).start();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement