From 9fe5ba444e6622fa96216873e59af1cad7ec081e Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 21 Jun 2017 23:10:36 -0700 Subject: Finalize sub item preferences --- .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sample/src/main/kotlin/ca') diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index d4c8c6e..0ec6ca0 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -90,6 +90,30 @@ class MainActivity : KPrefActivity() { true } } + + subItems(R.string.sub_item, subPrefs()) { + descRes = R.string.sub_item_desc + } + } + + fun subPrefs(): KPrefAdapterBuilder.() -> Unit = { + toolbarTitleRes = R.string.sub_item + text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) { + descRes = R.string.text_desc + onClick = { + itemView, _, item -> + itemView.context.materialDialog { + title("Type Text") + input("Type here", item.pref, { + _, input -> + item.pref = input.toString() + reloadByTitle(R.string.text) + }) + inputRange(0, 20) + } + true + } + } } override fun onCreate(savedInstanceState: Bundle?) { -- cgit v1.2.3