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:
Now the appearance when the menu button is 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).