Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Richard Luick
10,955 PointsAction Bar Up Button as the Back Button
I am playing around with the Ribbit app and came across this navigation scenario which I will explain using three activities: A, B, and C. With activity A being the parent to both B and C.
From activity A, you can navigate to both activity B and C:
A -> B
A -> C (Scenario 1)
However, you can also get to activity C through Activity B:
A -> B -> C (Scenario 2)
In both scenarios, hitting the "up" button will return you to the parent activity A (which is defined in the manifest). This is okay for Scenario 1, however, in Scenario 2, I would like clicking the up button to act similar to the back button and bring you back to activity B. Anyone have any insight on how to adjust the up button in scenarios like this? Thanks,
1 Answer
Greg Hesp
1,808 PointsThe way it is working, is the correct way it should work, and it should remain like that to allow consistency between your app and the android system.
Take a look here: http://developer.android.com/design/patterns/navigation.html
Essentially, the back button is a chronological button which takes you back to the previous screen, but the Up button takes you back to the parent.
An example of this would be: You open Gmail and then a message. In both cases, back and up would do the same thing.
However, lets say in the email, there was a link to Google Maps. If you click the link to Google Maps then it would load the Maps application. To get back to the Gmail message, you would use the back button.
By adding the back functionality to the up button, you are essentially removing a "shortcut" that is consistent across the operating system
Richard Luick
10,955 PointsRichard Luick
10,955 PointsOkay, I understand the difference between the two and how they are both supposed to work but I am just curious if it is possible to alter how the up button functions.
For example, in a given app, you may be able use the menu bar to access the "Settings" from a handful of different activities with only one of them technically being the parent. However, it would make sense if (at least to me) if hitting the up (or back) button in a certain circumstance could bring you back to the page you were on when you clicked on the "Settings" tab. Or is it just convention to only have access to the "setting" bar from a single parent activity?