Skip to content

PreferenceHeader

Marc Auberer edited this page Feb 3, 2021 · 1 revision

Allows you to pass a layout resource to your settings screen, respectively a page of your screen.

Usage example

You can place the Header tag in the root element of the settings configuration or within a Page element. Headers are currently only supported for code configurations.

Single paged example

SimpleSettings(this).show {
	Header {
		layoutResource = R.layout.header
	}
    Section {
        title = "Section"
        DropDownPref {
            title = "DropDownPreference"
            simpleSummaryProvider = true
            entries = listOf("Apple", "Banana", "Avocado", "Pineapple")
        }
		/*...*/
    }
    /*...*/
}

Multi-page example

SimpleSettings(this).show {
	Header {
		layoutResource = R.layout.header_root
	}
    Section {
        title = "Section"
        Page {
            title = "Page 1"
            summary = "Demo summary 1"
            displayHomeAsUpEnabled = false
			Header {
				layoutResource = R.layout.header_page1
			}
            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"
        }
    }
    /*...*/ 
}