Reputation: 21
I have 40 ImageViews inside a GridLayout, they have different colors and I want to know if user touched the desirable image or somewhere else(for example if user touched red image). How should I do that?
Upvotes: 0
Views: 930
Reputation: 280
If you manage your images in a collection maybe think about switching to gridview and implement an adapter with an itemClickListener. So depend on which item is clicked do you action. How GridLayout items come from the Adapter(List/Image) in Android App
Upvotes: 0
Reputation: 816
Set an OnClickListener
for each view and store the views. In onClick
you can check the view and know what ImageView was clicked. You could also think about changing the type to ImageButtons
!
If you have further problems with your Grid not being able to be clicked, check this out: http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/
TLDR: Disable focusing of the views in your layout.
Upvotes: 1