App Lab Back Button

One of my groups was working on their app in app lab and had incorporated a back button but are not sure how to code this. Has anyone tried this or know how to code this?

Could you post the link to the project to see what they have so far? Might be easier to help.

1 Like

https://studio.code.org/projects/applab/aiswwZ2D-FsnpVixRdRXebZK2PKNF0DmI6s74F6afZs

So far they have the app coded to go to all of the other pages from the home screen but are working to get those screens coded to come back to the home screen. They already have the “map” and “Settings” pages set this way. However we aren’t sure how to make the app realize what screen they were on previously for the “go back” button. I hope that makes sense!

1 Like

I think I understand what the student is trying to do. Most of the pages do not need the back button because the Home page is the previous screen which can be accessed with the “Home Button”.
But when you click on the Question Mark, you go to a screen where you can click on “Survey”. In order to get back to the previous screen the student needs to add this code to the Survey code:

image

1 Like

Jami,

Karen’s code is the best way to do this. If you have any advanced students, they can start thinking about assigning the screens to a variable and then based on that variable the app “knows” what screen they are on. It’s a more efficient way to work through navigation (mainly because the back button would always be currentScreen - 1).

Brad

Thanks we will try this!