Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

ModernAndroidPreferences

Latest release Build status License

Android Preferences defined through Kotlin DSL, shown in a RecyclerView.
No XML, no awful PreferenceManager, Fragments or styling problems, no more ListView. 🎉

Code example

// Setup a preference screen
val screen = screen(context) {
    pref("first") {
        title = "A preference"
        summary = "Click me to do stuff"
        click {
            doStuff()
        }
    }
    pref("second") {
        title = "Another one"
        iconRes = R.drawable.preference_icon_24dp
    }
    categoryHeader("more") {
        titleRes = R.string.category_more
    }
    switch("toggle_feature") {
        title = "Also supports switches"
    }
    // and many other preference widgets!
}

// Wrap the created screen in a preference adapter…
val preferencesAdapter = PreferencesAdapter(screen)

// …that can be attached to a RecyclerView
recyclerView.adapter = preferencesAdapter

View the example app

Example Activities (with and without using ViewModel) show advanced info like back handling, saving/restoring scroll position, and using the OnScreenChangeListener.

Include to project

ModernAndroidPreferences is on Bintray, so you can get it like any other dependency via JCenter:

dependencies {
    implementation 'de.Maxr1998.android:modernpreferences:1.0'
}

License

Copyright © 2018-2020 Max Rumpf alias Maxr1998

This library is released under the Apache License version 2.0. If you use this library (or code inspired by it) in your projects, crediting me is appreciated.

The example application however is licensed under the GNU General Public version 3, or any later version.

You can’t perform that action at this time.