17

I've been able to add all of my markers to my map, using locations provided by my API, but I've been unable to add an ActionBar.

As mentioned, I am using the Android Studio "Google Maps Activity" template. How can I go about adding an ActionBar to this template?

Please let me know if there's any code that you need from me.

ztnark
  • 329
  • 1
  • 2
  • 10
  • The default template already displays an ActionBar in my case.. – Simas Jan 16 '15 at 18:47
  • @user3249477 Hmm... The template itself gives the impression it would have an actionbar, but when I actually build the project, nothing. – ztnark Jan 16 '15 at 19:08
  • This information about your app might help: minSdk, targetSdk, activity style and device API version. – Simas Jan 16 '15 at 19:11
  • @user3249477 minsdk: 18, target sdk: 21, theme: Theme.AppCompat.Light.DarkActionBar, and device API version 19. Thank you! – ztnark Jan 16 '15 at 19:18

3 Answers3

62

Extending AppCompatActivity instead of FragmentActivity helped me.

Damian Kozlak
  • 7,065
  • 10
  • 45
  • 51
GeorgeK
  • 636
  • 7
  • 4
  • 2
    This should be the accepted answer. The current accepted answer does not solve this problem!! – pedroremedios Feb 06 '16 at 23:14
  • Agreed @pedroremedios! This solution worked for me. I will flag the other answer that was originally accepted which did not work. – AdamHurwitz Mar 23 '16 at 12:33
  • Works for me, by changing `FragmentActivity` to `AppCompatActivity` – BK19 Oct 12 '16 at 09:39
  • Along with this, placing the toolbar after MapFragment in Layout file worked for me. If Toolbar is before MapFragment, map sits on top of it and hides the toolbar – Siva Prakash Jul 30 '18 at 09:41
2

Since your minSdk is 18, you shouldn't be using the support theme (AppCompat). Change it to holo:

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

Also make sure your activities extend Activity or FragmentActivity.

Simas
  • 43,548
  • 10
  • 88
  • 116
  • 1
    my activity extends `FragmentActivity` and `miniSDK` is `15` what to do. when I try `` android studio give no suggestions. – Inzimam Tariq IT Nov 08 '15 at 14:01
  • I have all of the above mentioned, but this solution did not work for me. However, the solution from @GeorgeK on this page of changing **extends FragmentActivity** to **AppCompatActivity** fixed it. – AdamHurwitz Mar 23 '16 at 12:32
1

I followed this example https://developer.android.com/training/appbar/setting-up.html and I changed my coordinator layout to relative layout so that I could position my map fragment and other buttons below the toolbar.

Galileo
  • 321
  • 4
  • 7