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 Implementing Designs for Android Updating Other GridViews Updating the Recipients Activity

Jay Mayu
Jay Mayu
6,805 Points

Hiding menu item vs Hinding View

We learned in the lesson that to hide the menu item

mSendMenuItem.setVisible(true);

to hide a View

checkImageView.setVisibility(View.VISIBLE);

But when I follow the same pattern to hide the menu item the code challenge throws syntax error. Also the question also hints to hide the menu item similar to the way we hide View. Can someone enlighten me please.

1 Answer

Rydell Ward
Rydell Ward
10,215 Points

Did you make sure you get the item and set it to a member variable in the onCreateOptionsMenu method first like so:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.recipient, menu);
        mMenuItem = menu.getItem(0);
        return true;
    }
Jay Mayu
Jay Mayu
6,805 Points

Thanks for the answer. It's been a while since I did the challenge. Forgot what I did :)