1

I am trying to build an app for Android 4.0 and above using ActionBar. I am disappointed because the code examples related to ActionBar underlies in ActionBarSherlock, and I don't wanna use any external library. Is not there any workaround examples in commonsware to deal with the native ActionBar without using any external library or even without the android support library? Thanks

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Fran
  • 417
  • 2
  • 6
  • 15
  • these 2 actionbars are that similar that your can just remove the "support" from most of the methods and objects and they will refer to the native actionbar. – Daniel Bo Jan 27 '14 at 14:40
  • You can use the default ActionBar without libraries but then you remove yourself 30% of the userbase (Yes, 30% are still on Gingerbread). – galex Jan 27 '14 at 15:10

1 Answers1

6

I am disappointed because the code examples related to ActionBar underlies in ActionBarSherlock, and I don't wanna use any external library.

The core chapters of my book were overhauled in 2012. At that time, Android 2.x was dominant, and so an action bar backport was essential. At the time, the only viable backport (IMHO) was ActionBarSherlock.

I will be re-overhauling these chapters sometime later this year, once Android Studio stabilizes. At that time, I will be removing ActionBarSherlock and making the minor changes to have them use the native API Level 11+ action bar.

IOW, a technical book steers like a ship; a ~2,600-page book steers like an aircraft carrier. :-)

Is not there any workaround examples in commonsware to deal with the native ActionBar without using any external library or even without the android support library?

Various projects in the book use native API Level 11+ APIs, as I am not generally writing new ActionBarSherlock-based examples (except where I am copying an existing example).

Beyond that, to use the native API Level 11 action bar, all you do is:

  • Replace Theme.Sherlock (or whatever) with your choice of theme (e.g., Theme.Holo.Light.DarkActionBar)

  • Remove the ActionBarSherlock JAR

  • Replace Sherlock* classes with their regular equivalents (e.g., SherlockActivity becomes Activity) and adjust imports as needed

  • Most, if not all, of your getSupport*() methods, like getSupportActionBar(), convert to their non-Support equivalents (e.g., getActionBar())

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks. It would be very useful to add a chapter about native ActionBar, and leave external libraries as a further or advanced reading. – Fran Jan 27 '14 at 16:42