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

6,862 Points

Camera button outside of "Logout/Edit friends" options? How?

I had a quick question as I'm confused in the method where the Menu choices are in "onOptionsItemSelected(MenuItem item)"

if you see it is a switch statement with three cases or options as we see in the app, which are

**1. case R.id.action_logout:**

 **2. case R.id.action_edit_friends:**

 **3. case R.id.action_camera:**

my question is why does the "Logout" and "EditFriends" options stays together in a separate small window, and the camera button is outside in the actionbar. Arent they all supposed to be together side by side as that seems more logical with the switch statement code.

Anyone explain please?

2 Answers

If you want the camera option in that same drop down then you can change the value in android:showAsAction="always" to "never" from "always" in the main.xml file for the action_camera item. Having it available in the action bar is a better user experience since it's an option that will be used often for this kind of app.

Andre Colares
Andre Colares
5,437 Points

Here is the main.xml for correct function at Android Studio 1.4

<menu xmlns:android="http://schemas.android.com/apk/res/android"

    <item android:id="@+id/action_edit_friends"

    <item android:id="@+id/action_logout"

    <item android:id="@+id/action_camera"