Difference between ActionBarSherlock and ActionBar Compatibility Difference between ActionBarSherlock and ActionBar Compatibility android android

Difference between ActionBarSherlock and ActionBar Compatibility


ActionBarSherlock vs ActionBarCompat:

I Just want to put few code difference between ActionBarSherlock vs ActionBarCompat Lib

 ActionBarSherlock vs ActionBarCompat **strong text**

We can migrate some apps from ActionBarSherlock to ActionBarCompat:

steps:

  1. Import AppCompat project.

  2. Replace SherlockFragmentActivity with ActionBarActivity.

  3. Replace SherlockFragment with Fragment.

  4. Change Menu, MenuItem and getSupportMenuInflater() references.Modify the way you get Action Views.

    mSearchView = (SearchView)MenuItemCompat.getActionView(mSearchItem)

  5. Modify your Themes and Styles.

For more info, please refer this slides by +NickButcher (Google)

enter image description here

Thanks to Sources: http://gmariotti.blogspot.in/2013/07/actionbarsherlock-vs-actionbarcompat.htmlhttp://antonioleiva.com/actionbarcompat-migrating-actionbarsherlock/

Don't forget to read this developer.android for more about ABC!

Note: Setting it up for unit tests the same way as ABS is unfortunately not possible with the support library.

Output:

enter image description here

Credits: Gabriele Mariotti


ActionBarSherlock gives your application an action bar regardless* of what version of the android API your app is being run on. Action Bar Compatibility gives you the action bar only if the device that you're running on is API level 3.0 or above.

*Note that if the device you're running on isn't 3.0 or above, ActionBarSherlock is going to use it's own custom implementation of the action bar, not a native one.

--EDIT--

It appears things have changed and there is actually no difference between ActionBarSherlock and the Action Bar Compatibility anymore. Please read the comments below for details.

--EDIT--

After having used both now, I can say that I actually prefer ActionBarSherlock to Action Bar Compatibility. ActionBarSherlock is really easy and nice to use.

--EDIT--As LOG_TAG mentioned, there is now support for the action bar in the Android Support Library. I haven't had a chance to use it yet, but I would imagine that's the best one to use.


Just completing what @Kurtis Nusbaum with a pratical example.

UPDATE: as @rudy-s said, with newest android support library (api 18), I saw they already have built-in support for actionbar (called ActionBarCompat class).

I built two simple applications to show the visual difference between ActionBarSherlock and ActionBar Compatibility. See the comparatives images:

App using compatibility library

App using sherlock library

Now the appearance when the menu button is pressed:

App using compatibility on menu pressed

App using sherlock on menu pressed


As you can see, the images just enforce what was said. Action Bar Compatibility gives you the action bar only if the device that you're running on is API level 3.0 or above. While Sherlock is more general.

Below you can see the application source.

The menu xml file is the same:

<menu xmlns:android="http://schemas.android.com/apk/res/android" ><item    android:id="@+id/action_1"    android:orderInCategory="100"    android:showAsAction="always"    android:title="@string/action1"/><item    android:id="@+id/action_2"    android:orderInCategory="100"    android:showAsAction="ifRoom"    android:title="@string/action2"/><item    android:id="@+id/action_3"    android:orderInCategory="100"    android:showAsAction="ifRoom"    android:title="@string/action3"/><item    android:id="@+id/action_settings"    android:orderInCategory="100"    android:showAsAction="never"    android:title="@string/action_settings"/></menu>

Compatibility's activity:

public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);     }     @Override     public boolean onCreateOptionsMenu(Menu menu) {        getMenuInflater().inflate(R.menu.main, menu);        return true;     }}

Sherlock's activity:

public class MainActivity extends SherlockActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }    @Override    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {        getSupportMenuInflater().inflate(R.menu.main, menu);        return super.onCreateOptionsMenu(menu);    }}

An additional config was necessary on sherlock app:

<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">

UPDATE:as @rudy-s said, with newest android support library (api 18), I saw they already have built-in support for actionbar (called ActionBarCompat class).