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

Android Build a Self-Destructing Message Android App Starting the App Navigation with Back and Up

Derek Derek
Derek Derek
8,744 Points

Action bar not showing

I followed Ben step by step in my Android Studio but I can't get the action bar to show. My styles.xml does say DarkActionBar but I don't get why no action bar appears.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

I'd appreciate any help. Thank you!

2 Answers

Harry James
Harry James
14,780 Points

Hey hyunjaecho!

As Steve has pointed out here, the Action Bar is now deprecated, so we no longer use it and instead, new versions of Android use the Toolbar (Which, is backwards compatible when using the support library).

You can choose to use the new Toolbar, or follow my instructions below to continue using the DarkActionBar:

Add the following line to your build.gradle file for the app module under dependencies { }:

compile 'com.android.support:appcompat-v7:21.1.1'

(This is the latest appcompat at time of writing - Android Studio should show a warning if a new appcompat is available, or you can check the latest version here.)

Then, in styles.xml, use this appcompat theme:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->

That's all! You should now see your Action Bar :)

Note: It won't look exactly the same as on the video if you're running your emulator on a new SDK, such as Lollipop or Marshmallow. The appcompat library changes the appearance of the bar to best suit the OS style, which I personally think looks better.

If you want to be super old-hatt and use the same appearance as the video (There's no benefit to this), then continue using the Holo theme @android:style/Theme.Holo.Light.DarkActionBar but extend Activity - NOT ActionBarActivity.

Hope it helps and if you have any more questions, feel free to give me a shout :)

Thanks, Harry. :+1:

Hi there,

I think this course was retired from the Android track for reasons like this. The Android language moved on; action bars were deprecated and newer SDKs had different design ideas behind them. Updating this course became impossible so additional courses were added to the track, and this one removed. The changelog for the track is here.

I'm not sure if there's a solution for the action bar removal; maybe using an older SDK with the AppCompat features may assist. Harry James may be able to help with this - he keeps up to date with Android more than I do.