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

Android Build a Blog Reader Android App Using Intents to Display and Share Posts Easy Sharing with Intents

Dylan Cairns
Dylan Cairns
11,191 Points

ShowAsAction only available on newer API?

I'm going through the last few steps of the blog app and when I try to create the share icon it gives me a yellow warning in the xml view that : "Attribute "showAsAction" is only used in API level 11 and higher (current min is 8)"

The program still runs but it does not show the share icon. How do I get around this?

2 Answers

Heather Spence
Heather Spence
5,356 Points

Make sure you have app:showAsAction instead of android:showAsAction in your xml file. That is what worked for me.

<item android:id="@+id/action_share" app:showAsAction="always" android:icon="@drawable/ic_action_share" android:title="@string/action_share" />

Pablo Rocha
Pablo Rocha
10,142 Points

Make sure you have "always" as an app, not android.

    <item android:id="@+id/action_share"
          android:icon="@drawable/ic_action_share"
          android:title="@string/action_share"
          app:showAsAction="always"/>