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!
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

khaled doom
341 PointsActionBar 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();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
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

James Simshaw
28,738 PointsHello,
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.

khaled doom
341 PointsHello 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
actionbar.setNavigationMode();
it's deprecated in API Level 21 that i set as platform SDK

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