Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


ActionBar in API Level 21 !!

I am running Android Studio 1.0.1 and set my (compile SDK 21, and trying to type the following code :

import android.app.ActionBar;

ActionBar actionbar=getActionBar();

but find that method setNavigationMode(); has deprecated in API Level 21 that i run ,Then i tried to import the ActionBar from support.v7 to use getSupportActionBar();

import android.support.v7.app.ActionBar;

ActionBar actionbar=getSupportActionBar();

but this time i found that getSupportActionBar(); method is not available , so what is the solution now!!

I am waiting for your support guys , and Thanks in Advance

4 Answers


What is your activity extending? I believe for using the support library's ActionBar, you need to extend ActionBarActivity. If this isn't what you're looking for please let me know and we can try some other things.

Hello James ,,

i was extending (Activity) then i change it to (ActionBarActivity) as you advice , and import ActionBar from support library's ActionBar

now i can reach to : ActionBar actionbar=getSupportActionBar();

but still unable to use


it's deprecated in API Level 21 that i set as platform SDK

There aren't really that many options for getting around this that I know of. You can either ignore the deprecation warning, try one of the new design practices as mentioned here, or try one of the suggestions in the stackoverflow article I found here.

Hi James Thanks for your reply , I changed my platform SDK to 19 inorder to continue the project of Ribbit.