Cannot resolve symbol 'OnSeekBarChangeListener'

混江龙づ霸主 提交于 2021-01-28 04:02:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!