How To Handle Multiple Listeners Inside Gridview In Android
In my app, a GridView has list of contents. Each item is inflated with a layout. Single item inside the gridview contains, an image and 2 textviews. I have a requirement that whe
Solution 1:
In your view adapter, when you set the image resource, also set an onClickListener for the ImageView.
In my case, holder is a temporary static class which holds 2 TextViews and an ImageView.:
holder.mThumbnailImageView = (ImageView) convertView.findViewById(R.list.thumb);
holder.mThumbnailImageView.setImageResource(thisOrder.getIconValue());
holder.mThumbnailImageView.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
Toast.makeText(parent.getContext(), "image clicked: " + view.getId(), Toast.LENGTH_SHORT).show();
}
});
Post a Comment for "How To Handle Multiple Listeners Inside Gridview In Android"