N
N
Norton-nsk2020-07-03 13:56:05
Java
Norton-nsk, 2020-07-03 13:56:05

How to make the progressbars run in turn after the previous one is completed?

Hello!
I have 4 progress bars. After the counter starts, each progress bar in turn should run for 60 seconds, and the textView should display the countdown. How can I do that?

public class MainActivity extends AppCompatActivity {
 
    public TextView tv;
    public ProgressBar pb;
    public ProgressBar pb2;
    public ProgressBar pb3;
    public ProgressBar pb4;
    public Button bt;
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        tv = findViewById(R.id.timer);
        pb = findViewById(R.id.progress_bar);
        pb2 = findViewById(R.id.progress_bar2);
        pb3 = findViewById(R.id.progress_bar3);
        pb4 = findViewById(R.id.progress_bar4);
        bt = findViewById(R.id.button4);
 
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                
                new CountDownTimer(60000, 1000) {
                    @Override
                    public void onTick(long l) {
                        tv.setText("" + l / 1000);
                        pb.setProgress((int) (l / 1000));
                    }
 
                    @Override
                    public void onFinish() {
                        tv.setText("0");
                        pb.setProgress(0);
                    }
                }.start();
            }
        });
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2020-07-03
@leahch

Read about blocking queues java-online.ru/concurrent-queue-block.xhtml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question