Closed FrdsAlm closed 5 years ago
Hello, FrdsAlm. As far as i understand, you want to use one instance of listener for all fluid sliders. If it is so, you can simply create one listener as a function and store it in some reference. Then use it with any slider you want.
Example:
val positionListener = { pos -> slider.bubbleText = "${min + (total * pos).toInt()}" } val beginTrackingListener = { textView.visibility = View.INVISIBLE } val endTrackingListener = { textView.visibility = View.VISIBLE }
slider1.positionListener = positionListener slider1.beginTrackingListener = beginTrackingListener slider1.endTrackingListener = endTrackingListener
slider2.positionListener = positionListener slider2.beginTrackingListener = beginTrackingListener slider2.endTrackingListener = endTrackingListener
slider3.positionListener = positionListener slider3.beginTrackingListener = beginTrackingListener slider3.endTrackingListener = endTrackingListener
I want to use 5 of these sliders in my class project app and i have done it by assigning each one with a listner. it works but i was thinking if there is a way to do it in short way which will drastically reduce the code size. i tried to do it but unsuccessful. I dont have any experiance in kotlin. help will be appreciated