Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just some points regarding your code:</p> <p>You're probably getting only the first item with an overlay because you search with <code>findViewById</code> on the parent, the <code>GridView</code> and not the row view <code>view</code>, so <code>findViewById</code> will return the first <code>ImageView</code> that it finds(which is on the first visible row). In order to show that overlay you have some options on how to do it depending on the code that you used in the adapter's <code>getView</code> methodif you want to only show one item with an overlay at the time(for example, when you click one item, the previous one that was clicked(if any) will deselect) or if you have the options to toggle the item(click-> overlay, another click -> without overlay). Without knowing the information above this is how I would do it:</p> <pre><code>public void onItemClick (AdapterView&lt;?&gt; parent, View view, int position, long id) { ImageView overlay = (ImageView) view.findViewById(R.id.ItemOverlayImage); if (!items.get(position).isSelected()) { // the item doesn't have an overlay overlay.setImageResource(R.drawable.overlay); // set the overlay items.setSelected(true); // set to true so the adapter knows it } else { // the item has the overlay so we remove it overlay.setImageResource(0); items.setSelected(false); set to false so the adapter knows it } } </code></pre> <p>So long as you use in the <code>getView</code> method the <code>isSelected</code> to set or not set the overlay you'll be ok. </p> <p>Also you should remove the <code>FrameLayout</code> that wraps the <code>RelativeLayout</code>, as you don't do anything with it(?!?).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload