I am trying to take the value of a seekBar and if that value is within a certain range to change the textView.
if (olivine.getProgress()==50) {
rock.setText("Olivine rich");
};
This is what I have tried but it does not change the textView.
olivine.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar bar) {
int value = bar.getProgress();
}
public void onStartTrackingTouch(SeekBar bar) {
}
public void onProgressChanged(SeekBar bar,
int paramInt, boolean paramBoolean) {
olivineper.setText("" + paramInt + "%");
}
});
The above puts the seekBar value into a textView. I have multiple seekBars in the activity if that makes a difference.
Why don't you put your logic into the OnSeekBarChangeListener
?
public void onProgressChanged(SeekBar bar, int paramInt, boolean paramBoolean) {
if (paramInt==50) {
rock.setText("Olivine rich");
};
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.