0

I'm trying to implement a custom header menu (like a site nav) in my Android application and I'm wondering what the standard or best practice for creating a header menu? I'm thinking something like the facebook app that displays a logo and has some action items like triggering a search and possibly return back to the main activity. These are too be present at the top of my app in every activity, without the user having to click a button on the device.

Tab Layout doesn't seem to be what I'm looking for.

I found a tutorial here that might be close to what I'm looking for but not sure. It seems a bit redundant to instantiate a menu in every Activity. Seems like there would be a way to decouple the Activity from the menu, or at least more loosely couple it.

Perhaps I need to implement something with Fragments but I'm sort of new, so I'm not sure yet. Looking forward to your suggestions or hearing how you've implemented something like this. Thanks!

botbot
  • 7,299
  • 14
  • 58
  • 96

1 Answers1

1

Sounds like you're looking for the ActionBar pattern. See this old question and do your own Googling to find out more.

Community
  • 1
  • 1
kabuko
  • 36,028
  • 10
  • 80
  • 93
  • it's not very clear if ActionBar is the right solution for the problem I have. It looks like the ActionBar will only be present when the user interacts with the device buttons, not always present in the application. – botbot Jun 03 '12 at 00:49
  • No the action bar is always there. The Facebook app you mention is using this pattern. – kabuko Jun 03 '12 at 14:25
  • any suggestions as to why it wouldn't come up automatically? – botbot Jun 04 '12 at 03:03
  • Read through [the docs](http://developer.android.com/guide/topics/ui/actionbar.html). The ActionBar is only there automatically for 3.0+. Otherwise, you have to include a custom implementation like [ActionBarSherlock](http://actionbarsherlock.com/). – kabuko Jun 04 '12 at 06:10
  • thanks for the response. i'm using this in my Manifest.xml: which i believe sets it to 3.0, also using a Galaxy Note, so it should be coming up. eventually i'll use ActionBarSherlock, but as of now, just to get it up and running i'm using the build in ActionBar. – botbot Jun 04 '12 at 06:14
  • Unfortunately, there's a difference between targeting a certain version of the SDK and actually running on it. If your device has Android 2.3, you won't have the ActionBar unless you have a custom implementation like ActionBarSherlock no matter what you put in your manifest. – kabuko Jun 04 '12 at 16:53
  • i'm running on a Samsung Galaxy Note that should be SDK 4 Ice Cream Sandwich. – botbot Jun 05 '12 at 01:04