I use this in an app that I target Android 3.0+ only. I’d like to get more people but the ActionBar is not backwards compatible. I do not want to use a third party library like ActionBarSherlock. I went down that road and it was more of a pain then it was worth.
I have code like this:
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayHomeAsUpEnabled(true);
It is possible to wrap this with an if – else SDK check? Outside of the Action Bar, 99% other code is compatible pre-3.0 (well, I am using Fragments but using the Support Library.)
Yes, something like this:
Make sure to have your actionBar variable global