ztnark
ztnark

Reputation: 339

Adding an ActionBar to the Default Google Maps Activity Template in Android Studio

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.

Upvotes: 17

Views: 20264

Answers (4)

Giorgos Seimenis
Giorgos Seimenis

Reputation: 1

By default, the MapsActivity extends the FragmentActivity, which does not have the getSupportActionBar method.

Instead, make sure that your MapsActivity extends AppCompatActivity.

It worked for me and had no consequences at all in my code.

Upvotes: 0

Galileo
Galileo

Reputation: 321

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.

Upvotes: 1

GeorgeK
GeorgeK

Reputation: 636

Extending AppCompatActivity instead of FragmentActivity helped me.

Upvotes: 62

Simas
Simas

Reputation: 44158

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.

Upvotes: 2

Related Questions