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 trialMarcio Almeida
4,579 PointsI dont understand why is always giving an error: mInviteMenuItem.setVisible(true);
In the challenge Hide Menu Item, is always given me an error. Here is the code I write:
if(mGridView.getCheckedItemCount()>0{
mInviteMenuItem.setVisible(true);
}
5 Answers
Marcio Almeida
4,579 PointsThank you Harry.
I finish the challenge!!
Harry James
14,780 PointsHey Marcio!
It looks like it's just a silly mistake and you've missed out a bracket on your first line!
This:
if(mGridView.getCheckedItemCount()>0{
should look like this:
if(mGridView.getCheckedItemCount()>0) {
(I added another bracket at the end of the >0)
Hope it helps! :)
Marcio Almeida
4,579 PointsThanks for the quick answer, but after fix that error, I still have an error on the code, and I dont´t know why.
The challenge is: "If mGridView.getCheckedItemCount() is greater than 0, set the visibility of mInviteMenuItem to be visible. (Use the correct constant from the View class!)"
and I give this answer:
if(mGridView.getCheckedItemCount()>0){
mInviteMenuItem.setVisible(true);
}
and is given me the error:
./InviteActivity.java:36: error: cannot find symbol
mInviteMenuItem.setVisible(true);
^
symbol: method setVisible(boolean)
location: variable mInviteMenuItem of type MenuItem
1 error
Thank you for your help
Márcio
Harry James
14,780 PointsHey Marcio!
You're going to want to use setVisibility() and, read the question carefully because it tells you that "you should use the correct constant from the view class".
Hope this helps and if you're still stuck, give me a shout again and I'll tell you the answer (I try not to just write the answer straight off so that you can learn it yourself!) :)
Jery Althaf
5,818 PointsPlease help
if(mGridView.getCheckedItemCount() > 0){ mInviteMenuItem.setVisibility(0); } else{ mInviteMenuItem.setVisibility(1); }
doesn't work ?
Jery Althaf
5,818 PointsPlease help
if(mGridView.getCheckedItemCount() > 0){
mInviteMenuItem.setVisibility(0);
}
else{
mInviteMenuItem.setVisibility(1);
}
doesn't work ?
Harry James
14,780 PointsHey Jery!
Can you please provide a Logcat log so that I can take a look at where the problem is?
Thanks in advance :)
Harry James
14,780 PointsHarry James
14,780 PointsWoohoo! Glad you completed it!
If I answered your question, please mark my answer as the Best Answer so that other users know that this post has been answered.