I have made a ScrollView and filled it with ImageViews that have OnClickListeners attached to them, but now when I try to scroll the ScrollView, it seems that the OnClickListeners get in the way and don’t give a smooth scroll.
Is there a way to fix that, other then using a ListView instead of ScrollView?
Thanks!
You don’t have to have an OnClickListener for each ImageView.
The callback definition is
where
vis the view that was clicked.Depending on what you want to do, you can identify the specific view or not. IF you just want to do something generic, (for example, applying a tint), then this is very straightforward
If you need to identify the view specifically, e.g. it’s part of an XML menu, then I usually use the itemID to identify it
If the views aren’t static, then you can use the
setTag()andgetTag()methods to uniquely identify (and associate useful data!) with each view: