Skip to content

Commit 37c0ee3

Browse files
settings-activity: document defaults-to label for dont_persist rows
1 parent 208daf6 commit 37c0ee3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

docs/frameworks/settings-activity.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MyApp(Activity):
4040
- **`placeholder`** (string): Placeholder text for textarea input
4141
- **`changed_callback`** (function): Callback function called when the setting value changes
4242
- **`should_show`** (function): Boolean or function to determine if this setting should be displayed in the list
43-
- **`dont_persist`** (bool): If `True`, the setting won't be saved to SharedPreferences
43+
- **`dont_persist`** (bool): If `True`, the setting won't be saved to SharedPreferences. In the list, such a row shows "(not persisted)" — unless it also has a `default_value`, in which case it shows "(defaults to X)" like a normal unset setting (useful when the live value is re-read on every open).
4444
- **`min`** (int): Minimum value for `"slider"` UI (default: `0`)
4545
- **`max`** (int): Maximum value for `"slider"` UI (default: `100`)
4646
- **`activity_class`** (class): Custom Activity class for `"activity"` UI type
@@ -213,6 +213,12 @@ Use `dont_persist` to prevent a setting from being saved to SharedPreferences.
213213
}
214214
```
215215

216+
Such rows show "(not persisted)" in the list — unless a `default_value` is
217+
also given, in which case the row shows "(defaults to X)", re-read live on
218+
every open. That combination suits settings whose truth lives outside the
219+
app's own preferences (e.g. USB Host Mode, persisted under
220+
`com.micropythonos.usb`).
221+
216222
## Complete Example: Simple Settings List
217223

218224
Here's a minimal app that uses SettingsActivity to edit multiple settings:

0 commit comments

Comments
 (0)