Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get value from new android material design Slider

Using new material design slider com.google.android.material.slider.Slider. The documentation is quite poor for it as it has been just recently released. Trying to get value from slider but no luck for now. In other words, what would be a slider's equivalent of setOnProgressChanged { } from Seekbar.

like image 838
PLab Avatar asked Jun 16 '20 13:06

PLab


1 Answers

  Slider slider = findViewById(R.id.slider);
  slider.addOnSliderTouchListener(touchListener);

Then

private final OnSliderTouchListener touchListener =
      new OnSliderTouchListener() {
        @Override
        public void onStartTrackingTouch(Slider slider) {

        }

        @Override
        public void onStopTrackingTouch(Slider slider) {

        }
      };

For more details, Check SliderMainDemoFragment.java

like image 176
IntelliJ Amiya Avatar answered Sep 26 '22 09:09

IntelliJ Amiya