Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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"