The new Google Music app looks like it is using the new action bar API's with the split action bar items at the bottom. The cool thing is that it also works on my Nexus S Gingerbread phone, which doesn't have the new ICS API's. So, my question is of course how can I achieve that?
The Music app's action bar is a custom implementation, not a backport.
They are probably using some in-house / private action bar lib backported from ics.
Search for Sherlock Action bar lib. The new version 4.0 which will be out soon will allow you to use ics action bar api on older android versions.
You can add your own view at the bottom -- Linear Layout and add ImageButtons to this layout.
Related
I want to have a split action bar for android where the search widget is at the top action bar and the rest of the icons are in the bottom using android:uiOptions="splitActionBarWhenNarrow" is there a way to do that?
Thank you.
splitActionBarWhenNarrow is not supported by Theme.Material or the appcompat-v7 action bar backport.
If you wish to stick with something based off of Theme.Holo for all devices, you are welcome to use splitActionBarWhenNarrow.
If you wish to use either Theme.Material or appcompat-v7, you will need to create your own "split action bar", by having a Toolbar at the bottom of the screen that you populate separately.
For example, this sample project uses a Toolbar on API Level 21+ devices along with Theme.Material, gracefully degrading to having everything be in the action bar on Android 4.x devices.
I have a ListView in my ActionBarActivity that has items that can be long-pressed for additional actions.
I currently am using registerForContextMenu and showing an ugly popup dialog, so I want to change it to use a contexual action bar.
How can I do this? CHOICE_MODE_MULTIPLE_MODAL as well as a few other things seem to be API 11+.
What you want to use is ActionMode, http://developer.android.com/reference/android/support/v7/view/ActionMode.html, to implement the contextual action bar. The ActionMode is available in the ActionBarCompat library. Specifically you use ActionBarActivity#startSupportActionMode.
You can get a quick introduction in this document, http://android-developers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html. See the section entitled "7. Add ActionMode callbacks".
A more complete tutorial is available here, http://developer.android.com/guide/topics/ui/menus.html#CAB.
The Android API Guide for menus (same page that Matt cited) states that:
Note: The contextual action mode is available on Android 3.0 (API level 11) and higher and is the preferred technique for displaying contextual actions when available. If your app supports versions lower than 3.0 then you should fall back to a floating context menu on those devices.
If this is still true, then it means that Android does not support contextual action bars below API level 8. Can anyone please confirm if they have used it for Froyo or below?
I'm having serious problems getting tabs in actionbarsherlock below main action bar tabs to work in an app that runs from Android 2.2 up and looks like Android 4. (see link)
Tabs position
Have you tried running the official Demos app of ActionBar Sherlock? (https://github.com/downloads/JakeWharton/ActionBarSherlock/ActionBarSherlock-Sample-Demos-4.2.0.apk) It should contain a demo for the actionbar with Tabs.
If that works on Android 2.2 then you know the problem is in your code and you can check the Demos source code to see what you are doing differently (https://github.com/JakeWharton/ActionBarSherlock/tree/master/samples).
It's usual behavior of action bar (actionbarsherlock just simulate it). Use
ActionBar act = getSupportActionBar();
act.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.mytab_base_t));
to avoid white color in top bar (this option you can't access from any theme item yet). You can also monitor action bar height to change custom view of tabs on-fly, but you can't change action bar behavior, forget it. Otherwise please use PagerTitleStrip against action bar tabs.
Or is there a close equivalent to making this control work pre-ICS?
I got ActionBar covered with ActionBarSherlock, but I'm not sure how to get TabBar working the same way...
There is no TabBar in any version of Android.
If you mean "tabs in the action bar", ActionBarSherlock supports that.
I'd like to create a navigation menu in my Android app: a bar always at the bottom of the screen, with 4 choices Home|Categories|Search|Favorites, and the current page highlighted.
It seems the options menu can hardly be customized, so I can't use it.
Do I have to add this navigation bar in every layout or is there any better solutions?
Thanks
Julien
It sounds like you're replicating an iPhone interface. As most Android phones have buttons along the bottom of the screen (Home, Back, etc) it's likely to be a bad idea to put navigation there as it's easy to hit the wrong one.
The Google-recommended approach is to use the Action Bar pattern, across the top of the screen, which is very clear, and means your app is consistent with others (look at Twitter, Google Maps, Facebook - they all use the action bar pattern).
From Honeycomb (v3.0) onwards:
http://developer.android.com/reference/android/app/ActionBar.html
A simple library to create an Action Bar on any version of Android
https://github.com/johannilsson/android-actionbar
To create an action bar that uses that library on versions earlier than 3.0, but uses the official implemention for v3.0+, try this:
https://github.com/JakeWharton/ActionBarSherlock
The action bar is highly customisable, but remember that a key to a nice user interface is consistency across the platform, i.e. your app consistent with other apps and the OS.
If you need a navigation with more items or items within a specific page, you can use TabLayout, but for your primary nav, use the action bar, that's what it's for.
Use the TabLayout