You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/frameworks/setting-activity.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Each setting is defined as a dictionary with the following properties:
39
39
40
40
### Optional Properties
41
41
-**`ui`** (string): UI type to use for editing. Options: `"textarea"` (default), `"radiobuttons"`, `"dropdown"`, `"slider"`, `"activity"`
42
-
-**`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types
42
+
-**`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types. Each entry is a `(label, value)` tuple — the **label** appears on the radio button or dropdown row AND in the parent `SettingsActivity`'s value-label row beneath the title. The **value** is what gets stored in SharedPreferences. See [SettingsActivity → Display Labels for `ui_options`](settings-activity.md#display-labels-for-ui_options) for details.
43
43
-**`placeholder`** (string): Placeholder text for textarea input
44
44
-**`default_value`** (string): Default value to select or fill in
45
45
-**`changed_callback`** (function): Callback function called when the setting value changes
Copy file name to clipboardExpand all lines: docs/frameworks/settings-activity.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ class MyApp(Activity):
36
36
37
37
### Optional Properties
38
38
-**`ui`** (string): UI type for editing. Options: `"textarea"` (default), `"radiobuttons"`, `"dropdown"`, `"slider"`, `"activity"`
39
-
-**`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types
39
+
-**`ui_options`** (list): Options for `radiobuttons` and `dropdown` UI types. Each entry is a `(label, value)` tuple — the **label** is shown in the picker AND in the row's value label below the title; the **value** is what gets stored in SharedPreferences. See [Display Labels for `ui_options`](#display-labels-for-ui_options) below.
40
40
-**`placeholder`** (string): Placeholder text for textarea input
41
41
-**`changed_callback`** (function): Callback function called when the setting value changes
42
42
-**`should_show`** (function): Boolean or function to determine if this setting should be displayed in the list
@@ -132,6 +132,28 @@ Use a custom Activity class for advanced UI implementations.
132
132
}
133
133
```
134
134
135
+
## Display Labels for `ui_options`
136
+
137
+
For `radiobuttons` and `dropdown` settings, each entry in `ui_options` is a `(label, value)` tuple:
138
+
139
+
```python
140
+
"ui_options": [
141
+
("Lightning Piggy", "lightningpiggy"), # ← label ← stored value
142
+
("Lightning Penguin", "lightningpenguin"),
143
+
("None", "none"),
144
+
]
145
+
```
146
+
147
+
The settings-list row beneath each setting's title shows the **label** corresponding to the current stored value — not the raw value. So a row whose stored value is `"lightningpiggy"` displays "Lightning Piggy" below the title, matching what the user picked in the picker. This applies both on initial render and after a save.
148
+
149
+
If the stored value isn't present in the current `ui_options` list (e.g. a stale pref from before the option set changed), the raw value is shown unchanged rather than collapsing to "(not set)" — so the user can still see and recover from a now-invalid value.
150
+
151
+
Tips for choosing labels and values:
152
+
153
+
-**Labels** should be human-readable with spaces, casing, and punctuation as you want them shown to the user ("Lightning Piggy", not "lightningpiggy").
154
+
-**Values** should be machine-friendly identifiers — short, no spaces, stable across releases. They appear in SharedPreferences and in any export/import flows, so keep them URL-safe and ASCII when possible.
155
+
-**Don't change values for existing options** without a migration. The label can change freely (it's a presentation concern); the value is the identity.
0 commit comments