Question

The New York Times Android app offers section navigation using the spinner in the Action Bar. The user starts out on "Top News", and then if they navigate to another section, the content area is replaced and a left-pointing arrow for "Up" navigation is added to the Action Bar logo. No matter how many sections you switch between, if you hit the arrow-ed logo, you will always go back to "Top News". And if you go back to "Top News" using the Action Bar spinner instead of the arrow-ed logo, the logo loses its arrow appropriately. (Standard functionality.)

NYTimes screenshots

My initial approach to adapting this was to put the section content (a ListView) in a fragment, and replace that fragment inside the activity whenever the user changes sections. The content replacement works beautifully, but I haven't been able to implement the "Up" navigation, and I haven't found any good resources for doing so with fragments.

I'm wondering how I should design this. I see three major approaches:

  1. Continue to have all sections as part of one activity using fragments for content replacement. Implement "Up" navigation using a method (what?) I haven't been able to engineer or find.

  2. Give each section its own Activity, and launch a new Intent whenever the user opens a new one from the Action Bar's Spinner. Force the new Intent's Action Bar's Spinner to reflect that Activity's section on load.

  3. Same as #2, but give "Top News" equivalent its own activity rather than a variant of a section activity. Perhaps this would make more sense since the app launches onto "Top News", and I want it to be the top level for navigation.

Or maybe there's a better approach I haven't thought of. Design advice and links to relevant resources (especially resources with sample code or code advice, but I'll take what I can get) would be much appreciated.

Was it helpful?

Solution

The NY Times app has this functionality in one activity and uses View Pages to navigate between the different views. In order to conserve memory and allow support for low performance devices, it uses a scroll view to signal when an element should be loaded into memory via a custom MVC framework.

This is what was in place from 2011-2012.

How do I know? I wrote it. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top