Building your First Mobile App: App Logic
The app logic is responsible for toggling the visibility of the image and updating the button text accordingly. Follow these steps to implement the logic:
Navigate to the
Blocks
tab above theProperties
panel.Click on
Button1
in theBlocks
panel and drag thewhen Button1.Click
block.Drag an
if then else
block from theControl
section into thewhen Button1.Click
block.Drag an equal block from the
Logic
section and drop it into the if statement.Use the
Button1.Text
block from theButton1
section, placing it in the first section of the equal operation.Drag an empty text block from the
Text
section into the second part of the equal operation. Type Hide in the empty block.
Click on the
Image1
block and drag and dropset Image1.Visible to
on your screen. From theLogic
section grab theFalse
block. Connect them together.Similarly, click on the
Button1
block and drag and dropset Button1.Text to
on your screen. From theText
section grab the empty text block and typeS
how
. Connect them together.Move these two blocks inside the if statement.
Right-click on the first set block, choose
Duplicate
, and move the duplicated block inside the else statement. ChangeFalse
toTrue
andShow
toHide
.Duplicate the other block, move it into the else statement, and change the text to
Hide
. The final code is as follows:
Congratulations, you are done! Test your app to see the logic in action.
Last updated