gpt4 book ai didi

java - 搜索栏移动时显示进度

转载 作者:太空宇宙 更新时间:2023-11-04 12:54:54 25 4
gpt4 key购买 nike

我使用下面的代码在 Activity 中有一个进度条

 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();
}
});

移动搜索栏时,进度不会改变,当搜索栏停止时进度会改变。如何让搜索栏移动时进度也改变?

最佳答案

跟踪停止后,您在 TextView 中唯一设置进度,因此请在进度发生变化时进行设置:

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

关于java - 搜索栏移动时显示进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35489973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com