Mark M. | has entered the room |
Mark M. | turned on guest access |
Carlos | has entered the room |
Mark M. |
hello, Carlos!
|
Mark M. |
how can I help you today?
|
Jan 24 | 4:00 PM |
Carlos |
Hi Mark.
|
Carlos |
Try to get help on action bar "up navigation" over at stackoverflow, but haven't receive a good answer.
|
Carlos |
Can you take a quick look at this: goo.gl/6r4nx
|
Carlos |
Basically, I have a master/detail layout where in
the Activity I implement a listener that handles when "up navigation" is
used and another listener that handles edits from an items selected
from the listview.
|
Carlos |
I used the same fragment transactions for both
listeners, but the one for up nagivation results in the activity getting
restarted.
|
Mark M. |
are you sure that your android.R.id.home code is even getting invoked?
|
Carlos |
Yes it is
|
Mark M. |
do you have anything set up in your manifest related to this up navigation?
|
Carlos |
in the R.id.home inside the Details fragment I
call the onHomeSelected listener, which is implemented in both the
MainActivity (tablet configuration) and DetailsActivity (if phone
configuration).
|
Mark M. |
specifically, do you have android:parentActivityName on this activity?
|
Mark M. |
in the manifest, that is
|
Carlos |
let me take a quick look. I don't think so.
|
Jan 24 | 4:05 PM |
Carlos |
wait....
|
Carlos |
Where does that line is supposed to go?
|
Carlos |
My main activity has the following:
|
Carlos |
View paste
|
Mark M. |
well, in your case, it's probably *not* supposed to be there
|
Carlos |
That's the only activity in the tablet configuration.
|
Mark M. |
well, that seems fine
|
Mark M. |
if you comment out onHomeSelectedListener.onHomeSelected(); in your case android.R.id.home: block, what happens?
|
Mark M. |
in theory, Android should then do nothing at all on the home/up affordance press
|
Mark M. |
if, however, it *is* doing something, that's your problem, because it's probably still doing it despite your transaction
|
Carlos |
hmmm. I'll have to try that later tonight. Haven't pull the latest repo to this laptop.
|
Carlos |
Originally, I had the following in the onCreate method of the Details activity:
|
Carlos | |
Carlos |
but then it would only work for the phone configuration
|
Carlos |
I moved it inside the Details Fragment so that it would get called for both tablet and phone.
|
Carlos |
But then I encountered the issues I just described.
|
Mark M. |
well, technically, you're not going "up" on the tablet
|
Mark M. |
you are staying in the current activity
|
Carlos |
Yes, exactly.
|
Mark M. |
personally, I would not want to show the up arrow in that case
|
Carlos |
However, I haven't found an example on how to implement this behavior.
|
Mark M. |
implement what behavior?
|
Carlos |
The Tasks app in the Play Store is able to implement what I'm trying, so it is definitely doable.
|
Jan 24 | 4:10 PM |
Carlos |
The following...
|
Carlos |
While showing a detail fragment on the right-pane
(after user selected item from listview on left-pane), the user has 3
options to get out of viewing the detail framgnet and return to original
UI state.
|
Carlos |
1) press the back button, 2) press cancel/done/delete action bar items/buttons, 3) press app home icon button
|
Carlos |
Right now I only have 1 and 2 working properly
|
Mark M. |
and, IMHO, none of those are "up"
|
Carlos |
Yeah, the documentation regarding up and back is not very clean.
|
Carlos |
clear.
|
Mark M. |
I really dislike "up", which is why I am not covering it in the book
|
Carlos |
I know there is a different method that allows you
to select the app home icon for "back" operation without the "up
arrow". However, since this app that I used called "Tasks" was able to
implement the behavior I thought I would give it a try
|
Mark M. |
well, bear in mind that the up arrow you see in that app might not be supplied by the OS
|
Mark M. |
it could be part of the android:logo they use
|
Mark M. |
so, try removing setDisplayHomeAsUpEnabled() and just go with setHomeButtonEnabled(), and see if that helps
|
Carlos |
Hehehe. No mark, is the up arrow. It dissapears once you are in the home UI.
|
Carlos |
The Gmail app does it but since the are switching
between "email folder/email list" to "email list/email view" they have 2
separate activities and hence they don't have my issue.
|
Mark M. |
android:logo is a per-activity setting
|
Jan 24 | 4:15 PM |
Carlos |
I understand, but I truly now it is the up symbol everyone uses. Doesn't look part of the symbol.
|
Carlos |
anyways...
|
Carlos |
What you are saying is that since I'm dealing with
one activity and 2 fragments, then the concept of "up navigation" is
not valid because I'm already in the home activity. Correct?
|
Mark M. |
that would be why I would not put the up arrow there, ys
|
Mark M. |
er, yes
|
Carlos |
I see.
|
Carlos |
Yes, my gripe with up navigation is that it is not
consistent. But using "setHomeButtonEnabled()" is not very user
friendly because it is not easily discoverable. There is no cue to the
user that pressing the icon will return the UI to the home screen.
|
Mark M. |
considering it is one of three ways for them to move back in your flow, I wouldn't worry about it
|
Carlos |
Exactly. Most users will either press the back button or one of the Action Bar items.
|
Jan 24 | 4:20 PM |
Carlos |
Thanks for your feedback Mark. That was my only question for today. Have a good day!
|
Mark M. |
you too!
|
Carlos | has left the room |
Jan 24 | 5:00 PM |
Mark M. | turned off guest access |