搜索栏移动时显示进度

Display progress when seek bar is moving

我使用下面的代码在 Activity 中有一个 progress bar

 private SeekBar seekBar;
 private TextView progressText;

 seekBar=(SeekBar)findViewById(R.id.seekBarPercentage);
 progressText=(TextView)findViewById(R.id.textProgress);
 progressText.setText("Covered:" + "" + seekBar.getProgress() + "/" + seekBar.getMax());


     seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
                    progress = progresValue;
                   // Toast.makeText(getApplicationContext(), "Changing seekbar's progress", Toast.LENGTH_SHORT).show();
                }
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                  //  Toast.makeText(getApplicationContext(), "Started tracking seekbar", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    progressText.setText("Covered: " + progress + "/" + seekBar.getMax());
                   // Toast.makeText(getApplicationContext(), "Stopped tracking seekbar", Toast.LENGTH_SHORT).show();
                }
            });

移动搜索栏时,进度不会改变,当搜索栏停止时,它会改变。如何让seek bar移动的同时改变进度?

跟踪停止后您唯一在 TextView 中设置进度,所以在进度变化时进行:

@Override
public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser){
    progress = progresValue;
    progressText.setText("Covered: " + progress + "/" + seekBar.getMax());
}