问题
I'm trying to create a SeekBar listener, but for some reason the following:
final SeekBar birthdaySlider = (SeekBar) findViewById(R.id.birthdaySlider);
birthdaySlider.setOnSeekBarChangeListener(new birthdaySlider.OnSeekBarChangeListener() {});
Returns the error:
Cannot resolve symbol 'OnSeekBarChangeListener'
回答1:
Correct way to do :
final SeekBar birthdaySlider = (SeekBar) findViewById(R.id.birthdaySlider);
birthdaySlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
Tip: In Android Studio if you press ctrl+space keys, you will see autocomplete menu, which includes possible methods.
来源:https://stackoverflow.com/questions/37104266/cannot-resolve-symbol-onseekbarchangelistener