An open API service indexing awesome lists of open source software.

https://github.com/siavash79/rangesliderpreference

Android Preference based on RangeSlider
https://github.com/siavash79/rangesliderpreference

android library preference range slider

Last synced: about 1 year ago
JSON representation

Android Preference based on RangeSlider

Awesome Lists containing this project

README

          

# Range Slider Preference

This is a simple (yet very useful) library, based on com.google.android.material.slider.RangeSlider widget, to be used as Preference in Android's PreferenceScreen pages.

**The problem:**
Android's built-in SeekBarPreference can only include a single slider, thus can show/set only one value per preference. However, if you need to set ranges in preferences, there's no built-in Slider Preference available.

**Range Slider Preference** is able to show/set several values per preference, covering SeekBarPreference's shortcoming.

**How to include**
You can clone this repository using git, or simply add it to your project as a submodule (git submodule add https://github.com/siavash79/rangesliderpreference.git)

To use this preference in your apps, simply add this repository to your project as a module, and add the module to your app's dependencies.

You can then add it as a preference to your app settings page:


.
.

.
.

In the above example, you are setting a slider that operates 3 values that must be between 0 to 60, increase every 0.5 unit, and if the preference is not yet set, defaults to 3, 12 and 46.5.

RangeSliderPreference is also able to parse the values of your previously-set preference, if it's of any of types Integer, Float, or JSON string (Name/value, or name/array)

to read the preference values in your app, simply use the static method included:

List values = RangeSliderPreference.getValues(
myPrefrences /*SharedPreferences*/,
"MY_KEY" /* preference key */,
2 /* default value in case the preference was not found */);
and the value(s) will be presented in a List\ object.