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
Blockstab above thePropertiespanel.Click on
Button1in theBlockspanel and drag thewhen Button1.Clickblock.Drag an
if then elseblock from theControlsection into thewhen Button1.Clickblock.Drag an equal block from the
Logicsection and drop it into the if statement.Use the
Button1.Textblock from theButton1section, placing it in the first section of the equal operation.Drag an empty text block from the
Textsection into the second part of the equal operation. Type Hide in the empty block.

Click on the
Image1block and drag and dropset Image1.Visible toon your screen. From theLogicsection grab theFalseblock. Connect them together.Similarly, click on the
Button1block and drag and dropset Button1.Text toon your screen. From theTextsection grab the empty text block and typeShow. 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. ChangeFalsetoTrueandShowtoHide.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
Was this helpful?