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 Displaying Checkmarks in a GridView

'else' without 'if' else{ holder.overlayImageView.setVisibility(View.VISIBLE); }

im failing to proceed guys, getting that error, please help

'else' without 'if' else{ holder.overlayImageView.setVisibility(View.VISIBLE); }

PlayerAdapter.java
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.parse.ParseUser;

public class PlayerAdapter extends ArrayAdapter<ParseUser> {

    public GridView mGridView;

    /*
     * Some code has been omitted for brevity!
     */

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;

        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.player_item, null);
            holder = new ViewHolder();
            holder.playerImageView = (ImageView)convertView.findViewById(R.id.playerImageView);
            holder.overlayImageView  = (ImageView)convertView.findViewById(R.id.overlayImageView);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder)convertView.getTag();
        }

      mGridView = (GridView)parent; 
      if (mGridView.isItemChecked(position)){
        holder.overlayImageView.setVisibility(View.INVISIBLE);
      }
        else{
          holder.overlayImageView.setVisibility(View.VISIBLE);
        }

        /*
         * Add your code here! (Some code has been omitted for brevity)
         */
else{ holder.overlayImageView.setVisibility(View.VISIBLE); }

        return convertView;
    }

    private static class ViewHolder {
        ImageView playerImageView;
        ImageView overlayImageView;
    }
}

1 Answer

Look closely at your second if statement. There is an if block, an else block, a multi-line comment...and then another else block!