This is an easy to use custom preference, which opens a dialog with a number picker. The value gets automatically saved and you can set the default-, min- and maxValue conveniently in the XML.
<com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference
xmlns:vntnumberpickerpreference="http://schemas.android.com/apk/res-auto"
android:defaultValue="@integer/font_size_default_value"
android:key="preference_font_size"
android:title="@string/font_size"
vntnumberpickerpreference:vnt_maxValue="@integer/font_size_max_value"
vntnumberpickerpreference:vnt_minValue="@integer/font_size_min_value"
vntnumberpickerpreference:vnt_setWrapSelectorWheel="true"/>
or scan the code on your mobile
or download it directly
build.gradle
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
compile 'com.vanniktech:vntnumberpickerpreference:0.2.0-SNAPSHOT'
}
Go to your preference XML file and insert the above mentioned XML tag. Afterwards you are good to go and can run your project!
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
final int fonftSize = sharedPreferences.getInt("preference_font_size", this.getResources().getInteger(R.integer.font_size_default_value));
No configuration needed.
Copyright (C) 2014-2015 Vanniktech - Niklas Baudy
Licensed under the Apache License, Version 2.0