diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-21 23:10:36 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-21 23:10:36 -0700 |
commit | 9fe5ba444e6622fa96216873e59af1cad7ec081e (patch) | |
tree | d3c483528838ac8bcd3545424d807d8b1b434d15 /sample/src | |
parent | 621c083b4ee1a81c67665ebf4b442f0ea98b5d4a (diff) | |
download | kau-9fe5ba444e6622fa96216873e59af1cad7ec081e.tar.gz kau-9fe5ba444e6622fa96216873e59af1cad7ec081e.tar.bz2 kau-9fe5ba444e6622fa96216873e59af1cad7ec081e.zip |
Finalize sub item preferences
Diffstat (limited to 'sample/src')
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 24 | ||||
-rw-r--r-- | sample/src/main/res/values/strings.xml | 2 |
2 files changed, 26 insertions, 0 deletions
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<String>(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?) { diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 049a395..9c1e650 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -15,6 +15,8 @@ <string name="color_custom_alpha">This selector allows for custom colors with alpha values</string> <string name="text">Text Pref</string> <string name="text_desc">Saves the text</string> + <string name="sub_item">Sub Item Pref</string> + <string name="sub_item_desc">Press this to view the next subset of preferences</string> <string name="your_email">your.email@here.com</string> <string name="your_subject">Your subject</string> </resources> |