我在 Android 中将 SeekBar 用于我的反馈对话框。
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.feedbackview, (ViewGroup) findViewById(R.id.seekHospitality));
SeekBar hospitalitySeek = (SeekBar) layout.findViewById(
R.id.seekHospitality);
hospitalitySeek.setProgress(5);
hospitalitySeek
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
}
public void onProgressChanged(SeekBar seekBar,
int progress, boolean fromUser) {
if (seekBar.getId() == R.id.seekHospitality) {
TextView valHospitality = (TextView) getFeedbackDialog()
.findViewById(R.id.valHospitality);
valHospitality.setText(progress);
}
}
});
但是当我改变 SeekBar 的进度时,监听器永远不会触发。为什么?