title: Set only clickable the items inside the GridView
body: <p>I have a gridview with several items. They are clickable, but as you can see in the picture, when i press any part of the gridview item, everything is selected. My goal is to make only clickable the layout containig the image and textview (in each item of the GridView) .</p>
  
  <p>Secondly, I have also noticed that the "clicked effect" appears behind the layout and not in front (check the picture). Is there any way of changing that? </p>
  
  <p><a href="https://i.stack.imgur.com/6HudK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6HudK.png" alt="enter image description here"></a></p>
  
  <p>the gridview is set as follows:</p>
  
  <pre><code>mItems.add(new GridViewItem(resources.getDrawable(R.drawable.sman_package), getString(R.string.pick_package)));
  mItems.add(new GridViewItem(resources.getDrawable(R.drawable.sregister), getString(R.string.register)));
  mAdapter = new GridViewAdapter(this, mItems);
  // initialize the GridView
  final GridView gridView = (GridView) this.findViewById(R.id.gridView);
  gridView.setAdapter(mAdapter);
  gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          switch (position) {
              case 0:
  
                  break;
              case 1:
  
                  break;
          }
  
  
  
      }
  });
  </code></pre>
  
  <p>Where <code>GridViewItem</code> is</p>
  
  <pre><code>public class GridViewItem {
      public final Drawable icon;       // the drawable for the ListView item ImageView
      public final String title;        // the text for the GridView item title
  
  
      public GridViewItem(Drawable icon, String title) {
          this.icon = icon;
          this.title = title;
  
      }
  }
  </code></pre>
  
  <p>And <code>GridViewAdapter</code> is the following:</p>
  
  <pre><code>public class GridViewAdapter extends BaseAdapter {
      private Context mContext;
      private List&lt;GridViewItem&gt; mItems;
  
  
      public GridViewAdapter(Context context, List&lt;GridViewItem&gt; items) {
          mContext = context;
          mItems = items;
      }
  
      @Override
      public int getCount() {
          return mItems.size();
      }
  
      @Override
      public Object getItem(int position) {
          return mItems.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder viewHolder;
  
          if(convertView == null) {
              // inflate the GridView item layout
              LayoutInflater inflater = LayoutInflater.from(mContext);
              convertView = inflater.inflate(R.layout.gridview_item, parent, false);
  
              // initialize the view holder
              viewHolder = new ViewHolder();
              viewHolder.ivIcon = (ImageView) convertView.findViewById(R.id.ivIcon);
              viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle);
              //viewHolder.LayoutItem = (LinearLayout) convertView.findViewById(R.id.layoutItem);
  
  
              convertView.setTag(viewHolder);
          } else {
              // recycle the already inflated view
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          // update the item view
          GridViewItem item = mItems.get(position);
          viewHolder.ivIcon.setImageDrawable(item.icon);
          viewHolder.tvTitle.setText(item.title);
  
          return convertView;
      }
  
      /**
       * The view holder design pattern prevents using findViewById()
       * repeatedly in the getView() method of the adapter.
       *
       */
      private static class ViewHolder {
          ImageView ivIcon;
          TextView tvTitle;
  
      }
  }
  </code></pre>
  
  <p>I have checked several posts but I still haven't found a proper solution. If any of you has an idea of how to solve it I would really appreciate :)</p>