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 trialMichael Arsenault
15,352 PointsShare button does not include image, and is hidden as a sub-menu option.
The Eclipse/SDK files I am using are from the CrystalBall app tutorial (downloaded 19 April 2014). The versions are as follows:
Eclipse 4.3 for Mac OS X ADT - Build v22.6.2-1085508
Following the BlogReader tutorial, I've come to an issue with the share button we've just added. Mine does not display in the menu bar, as is the case in the tutorial, but is instead embedded within a sub-menu off of the menu bar (as shown in the image below)
When following the tutorial, the button was added to the menu bar via the xml file located in menu/activity_blog_web_view.xml
. For starters, I did not have said file (mine was menu/blog_web_view.xml
). Secondly, when clicking on "Add" to add a new menu element, I was not presented with any options in the dialog box, as shown below
I modified the file name (as well as any reference to it) and manually copied the button information in the .xml file. But what I get is the text-only share button embedded within a drop-down menu.
activity_blog_web_view.xml as follows:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_action_share"
android:showAsAction="always"
android:title="@string/action_share">
</item>
</menu>
Clicking on the "Share" button has the desired effect, just not the desired look.
Any thoughts? Please let me know if I can add any further details.
Thanks in advance.
5 Answers
Joshua Bearss
6,222 PointsI had to add a line in the xml file like:
xmlns:yourapp="http://schemas.android.com/apk/res-auto"
Then in the <item> declaration say:
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_action_share"
android:title="@string/action_share"
yourapp:showAsAction="always" />
to get it to show up properly.
Found this at http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems
Theodore Kruczek
8,800 PointsMake sure you have the most up-to-date versions of Android APK and Eclipse. That issue with "Create a new element at the top level, in temp." was resolved for me with a recent update (and only started about two weeks ago with another update).
Your code looks right to me. Try updating and let us know if that solves it or if there is another problem.
Michael Arsenault
15,352 PointsJust updated Eclipse and SDK from the Google Android developer site, but the issue persists. My experience with Android so far has been pretty bad. Lots of bugs, slow emulator, etc. Big headache.
Michael Arsenault
15,352 PointsIt's the onCreateOptionsMenu
method that was automatically created in the BlogWebViewActivity
class. Just remove it.
Masum Bergmann
Courses Plus Student 4,129 Pointsjust fyi, this solution did not work for me... when I removed onCreateOptionsMenu()
the options icon simply disapeared, and the share icon was still nowhere to be found.
Kevin Lavi
3,311 PointsWere you able to figure this out? I'm having the same issue currently and I followed each step as is.
Masum Bergmann
Courses Plus Student 4,129 PointsMasum Bergmann
Courses Plus Student 4,129 PointsFantastic! That did the trick... Thanks for that!