Posts

Showing posts with the label ActionBarCompat

ActionBarCompat and NavigationDrawer

Image
In previous posts I talked about new ActionBarCompat . ActionBarSherlock vs ActionBarCompat How to add ActionBarCompat to your project In this post we'll try to use ActionBarCompat with the NavigationDrawer . If you have already implemented a NavigationDrawer with ActionBar, it is very easy to migrate to ActionBarCompat. I will use code I wrote with post Creating a Navigation Drawer . Here you can see steps: First of all you have to add ActionBarCompat to your project. Then: In your Activity you have to extend ActionBarActivity . Change getActionBar() with get getSupportActionBar() . Pay attention with invalidateOptionsMenu() . You have to change it with supportInvalidateOptionsMenu(); It is very easy! Some last tips: Be careful not to use attributes that work only with API 14+ , like ?android:attr/listPreferredItemHeightSmall or ?android:attr/textAppearanceListItemSmall . In this case you can use different styles using folder values-v14. Be careful w...

How to add ActionBarCompat to your project.

Image
In my previous post I've talked about a comparison between ActionBarSherlock and ActionBarCompat. In this post we'll try to add ActionBarCompat to our project . It is pretty simple to use and implement ActionBarCompat, but we have to pay attention when we add it to our project. In Android Studio it is very very simple. Open build.gradle and add this: dependencies { compile 'com.android.support:appcompat-v7:18.0.+' } In ADT (Eclipse) you can add it as a library project based on code that you can find in sdk\extras\android\support\v7\appcompat . It is described here . Pay attention. In your project you have to add this library project. Now it is very simple to review our code. In Activity we have to extend ActionBarActivity . If you see source code it extends a FragmentActivity . import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.support.v7...

ActionBarSherlock vs ActionBarCompat

Image
Now ActionBarCompat is published and is available in the Support Library for compatibility with Android 2.1 (API level 7) and above. Here a very little comparison between ActionBarSherlock and ActionBarCompat . Some screenshots: One last tip. There is a great similarity: