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 Self-Destructing Message Android App Capturing Photos and Videos Adding a Camera Button in the Action Bar

Camera Icon wont add to Action Bar

I have changed the xml file (main.xml) to change the overflow menu in the mainactivity, but for some reason the picture wont show up. I still am only getting the original items (log out and edit friends). Did anybody else come across this issue?

3 Answers

besides the fact that I forgot the "@" before "drawable/ic_..." it still doesnt work after that is fixed.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

If you have the @ symbol in there then everything matches my own project. Can you try cleaning and reinstalling your project?

  1. In Eclipse, select Project > Clean.
  2. Uninstall the app from your emulator or device.
  3. Run it again

If you still have trouble, can you add a screenshot of how your app looks? Can you verify that ic_action_camera looks okay?

i had to change

android:showAsAction="always"

to

app:showAsAction="always"

I'm not sure why that made the difference.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Ah, I think this may have to due with the fact that the support library is now being included in the projects when we start. The tools were updated this way recently. Here's a StackOverflow question that talks about this problem: http://stackoverflow.com/q/17914017/475217 I'm going to see about adding a note to address this. Sorry for your trouble!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Paste your main.xml menu layout and we'll have a look. :)

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.marcojonker.ribbit.MainActivity" >

<item
    android:id="@+id/action_edit_friends"
    android:title="@string/menu_edit_friends_label">
</item>
<item
    android:id="@+id/action_logout"
    android:title="@string/menu_logout_label">
</item>
<item
    android:id="@+id/action_camera"
    android:icon="drawable/ic_action_camera"
    android:showAsAction="always"
    android:title="@string/menu_camera_label">
</item>

</menu>

thanks.