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 trialAlex Hexan
Courses Plus Student 769 PointsCamera icon not showing up
The camera icon just won't show up on the action bar. It does in the overflow menu but only as "Camera" that's it. Here is my <item/> code
'''xml
<item android:id="@+id/menu_camera"
android:title="@string/menu_camera_label"
android:icon="@mipmap/ic_camera_white_18dp"
android:showAsAction="ifRoom" />
'''
7 Answers
Arthur Dejardin
6,451 PointsTo anyone facing the same problem: I solved it by having app:showAsAction="always" instead of android:showAsAction="always" in the menu_main.xml
Cheers, Arthur
Abhin Iype
Courses Plus Student 4,615 PointsHi, I'm having the same problem: its showing up in the overflow menu even after i added android:showAsAction="always".
<item android:id="@+id/menu_camera"
android:title="@string/menu_camera_text"
android:icon="@mipmap/ic_action_camera"
android:showAsAction="always"/>
Help please.
Abhin Iype
Courses Plus Student 4,615 PointsNever mind I figured it out: It should be: app:showAsAction="always" because of the: xmlns:app="http://schemas.android.com/apk/res-auto" which includes the support library.
Eleni Minadaki
3,687 PointsHi Alex.i am so sorry i haven't done yet that lesson. Hope find it soon!
Alex Hexan
Courses Plus Student 769 PointsIt's alright, Please tell me when you do.
Arthur Dejardin
6,451 PointsHi guys,
Same problem here ! Anyone got it working?
Thx, Arthur
Joshua Douce
13,120 PointsHad the same problem thanks for the answer Arthur
amir baldiga
2,530 Pointsproblem Solved!!!
add: menu.add(0, 0, 0, "androidDemo").setIcon(R.drawable.ic_action_camera);
to: public boolean onCreateOptionsMenu(Menu menu) {
Andre Colares
5,437 PointsHere is the main.xml for correct function at Android Studio 1.4
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
<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:title="@string/menu_camera_label"
yourapp:showAsAction="ifRoom"
></item>
</menu>