Question

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

Was it helpful?

Solution

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())

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