Skip to content

PreferencePage

Marc Auberer edited this page Dec 23, 2020 · 1 revision

Represents a nested settings screen. Whenever a page is used in your configuration, there will only be a text preference with a customizable title and summary. You can click on this item and another activity will show up which is fully customizable. It shows the subset of sections (containing more items), which you defined within the scope of your page element.

Usage example

Simple example with a main screen, containing three items. The first item is a page item and is clickable. As soon as you click the item, another settings screen will open up and shows Option 1 and Option 2.

SimpleSettings(this).show {
    Section {
        title = "Section"
        Page {
            title = "Page 1"
            summary = "Demo summary 1"
            displayHomeAsUpEnabled = false
            Section {
                title = "Demo subsection"
                TextPref {
                    title = "Option 1"
                    onClick = LibsClickListener(this@MainActivity)
                }
                TextPref {
                    title = "Option 2"
                    summary = "Option 2 Text"
                }
            }
        }
        DropDownPref {
            title = "DropDownPreference"
            simpleSummaryProvider = true
            entries = listOf("Apple", "Banana", "Avocado", "Pineapple")
        }
    }
    Section {
        InputPref {
            title = "InputPreference"
            summary = "Click to set text"
            defaultValue = "Default text"
        }
    }
    /*...*/ 
}