Note that there are some explanatory texts on larger screens.

plurals
  1. POImageAdapter onClick goes wrong
    primarykey
    data
    text
    <p>I'm trying to set an onClick listener on my ImageView in the Adapter of my GridView. However, weird thing happens: The content of the onClick function affects also some other Views in my GridView.</p> <p>There is a good reason that I don't do the click listener on my GridView, so I need a solution for this via the ImageAdapter.<br> The logcat is called only once I click, but for some reason, other ImageViews are affected by this function.</p> <p>Here's relevant code:</p> <pre><code> public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder holder; if(convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.row_multiphoto_item, null); holder.tickImageView = (ImageView) convertView.findViewById(R.id.tickImageView); holder.imageView = (ImageView) convertView.findViewById(R.id.imageView1); holder.imageViewLayout = (LinearLayout)convertView.findViewById(R.id.imageViewLayout); convertView.setTag(holder); } else{ holder = (ViewHolder) convertView.getTag(); } holder.imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ImageView imageView = (ImageView)v; int id = imageView.getId(); imageView.setVisibility(View.GONE);/* if(!thumbnailsselection[id]){ Log.d(Global.TAG, "CLICK"); holder.tickImageView.setVisibility(View.VISIBLE); holder.imageViewLayout.setBackgroundResource(R.drawable.imageview_selected); thumbnailsselection[id] = true; } else{ holder.tickImageView.setVisibility(View.GONE); holder.imageViewLayout.setBackgroundResource(R.drawable.imageview_unselected); thumbnailsselection[id] = false; } */ } </code></pre> <p>});</p> <pre><code> holder.imageView.setId(position); holder.imageViewLayout.setId(position); holder.tickImageView.setId(position); holder.imageView.setImageBitmap(thumbnails[position]); return convertView; } class ViewHolder { ImageView imageView; LinearLayout imageViewLayout; ImageView tickImageView; int id; } </code></pre>
    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.
    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