Office Hours — Today, January 24

Tuesday, January 22

Mark M.
has entered the room
Mark M.
turned on guest access
Carlos
has entered the room
Mark M.
hello, Carlos!
how can I help you today?
Jan 24
4:00 PM
Carlos
Hi Mark.
Try to get help on action bar "up navigation" over at stackoverflow, but haven't receive a good answer.
Can you take a quick look at this: goo.gl/6r4nx
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.
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?
in the manifest, that is
Carlos
let me take a quick look. I don't think so.
4:05 PM
Carlos
wait....
Where does that line is supposed to go?
My main activity has the following:
View paste
 <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
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
if you comment out onHomeSelectedListener.onHomeSelected(); in your case android.R.id.home: block, what happens?
in theory, Android should then do nothing at all on the home/up affordance press
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.
Originally, I had the following in the onCreate method of the Details activity:
View paste
 ActionBar actionBar = getSupportActionBar();  
            actionBar.setDisplayHomeAsUpEnabled(true);
but then it would only work for the phone configuration
I moved it inside the Details Fragment so that it would get called for both tablet and phone.
But then I encountered the issues I just described.
Mark M.
well, technically, you're not going "up" on the tablet
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.
4:10 PM
Carlos
The following...
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.
1) press the back button, 2) press cancel/done/delete action bar items/buttons, 3) press app home icon button
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.
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
it could be part of the android:logo they use
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.
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
4:15 PM
Carlos
I understand, but I truly now it is the up symbol everyone uses. Doesn't look part of the symbol.
anyways...
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
er, yes
Carlos
I see.
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.
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
5:00 PM
Mark M.
turned off guest access

Tuesday, January 22

 

Office Hours

People in this transcript

  • Carlos
  • Mark Murphy