beetlebug

ztk::android::Screen

Makes a screen: a ScrollView with a column of views (LinearLayout), with margins of 16 dp and 16 dp between views.

Light Dark
A Settings screen of Android: the title Settings in the toolbar, the label Name over a text field, the row Daily reminders with a switch, the button Save in the accent color, and the gray button About The same screen in the dark mode of Android

Synopsis

ztk::android::Screen new ?-title TEXT?

Arguments

Name Type Default Meaning
-title text empty The title in the toolbar of the navigation stack.
add KIND ?OPTION VALUE ...? method Makes a control of KIND with the options, puts it at the end of the column, and gives the object. KIND is label, button, switch, datepicker, textfield, textview, or stack.
views method Gives the controls of add, in their order.
push SCREEN method Shows SCREEN on the navigation stack of this screen.
pop method Goes back to the screen under the top one.
navigationStack method Gives the navigation stack of the screen, or an empty string.
closed method Runs when the screen leaves its navigation stack, before the screen is destroyed. The method of Screen is empty, and a subclass overrides it.

Return value

new and add give an object. views gives a list. push and pop give an empty string.

Errors

Error When
bad kind "KIND": must be button, datepicker, label, stack, switch, textfield, or textview add has another kind.
the screen is not on a navigation stack push or pop on a screen of no stack.

Platforms

Platform Works
Windows No
macOS No
Linux, Wayland No
Linux, X11 No
Web No
iOS No: ztk::ios::Screen
Android Yes
Headless No: the namespace does not exist.

Example

oo::class create Counter {
    superclass ztk::android::Screen
    variable count label
    constructor {} {
        next -title Counter
        set count 0
        set label [my add label -text "0 taps" -font largeTitle]
        my add button -text "Add one" -command [list [self] tap]
    }
    method tap {button} {
        incr count
        $label configure -text "$count taps"
    }
}
ztk::android::app root [ztk::android::NavigationStack new [Counter new]]

See also