About: The checkbox allows the user to check an option which would indicate a yes/no true/false state.
This exercise lets you try out using checkboxes and sets the text in the title bar when the Eggs checkbox is changed for the first time.
Create a new project titled: lrn_cbx_shop
Screen Designer:
Click on the Title bar and change the Title Property text to Shopping List
Drag out 3 checkboxes and change their Text Properties to Bread, Milk and Eggs.
Blocks Editor:
Drag out CheckBox3.Changed from the My Blocks, CheckBox3 group
- this event block will execute any blocks inside it when it's box is changed from checked to unchecked or vice versa.
- CheckBox3 has the text label 'Eggs' and we want to remind mom to get the cholesterol-free eggs
- we want it to show the message 'Remember to get cholesterol-free! when the box is first checked
Drag out a set-Screen1.Title-to block from My Blocks, Screen1 and drop it inside CheckBox3.Changed
From the Built-In tab, text option, drag out a text-text block, snap it to Scrteen1.Title and change the text to 'Remember to get cholesterol-free!'
Now test your project with the emulator or attached android device.
- the output should look like this:
END.
Challenge:
Can you have the other checkboxes display a message when they are first checked?