I am a beginner in android studio. In an application there are five horizontal rows. In any row there are ten pics and properties of the pic. Click on any pic put extra to intent and direct to another activity. How can I write onclick event for all pics? Should I write 50 onclick events for all pics? Is there any other way? Thanks
Asked
Active
Viewed 45 times
-3
-
You using ImageView ? – Krish Apr 04 '17 at 09:45
-
how are you placing the images???? gridView???? share the code – AwaisMajeed Apr 04 '17 at 09:47
3 Answers
0
You can use GridView for the layout you are displaying. Refer Doc here. And example here.

Amey Haldankar
- 2,223
- 1
- 24
- 22
0
In this case you can use a GridView
. Here is an example answer where you can find how to do it:
Simple Android grid example using RecyclerView with GridLayoutManager

Community
- 1
- 1

androidcodehunter
- 21,567
- 19
- 47
- 70
0
Add to the ImageViews: "android:onClick="navigateToNextActitivy"
and declare the navigateToNextActitivy
-Method in your Activity and put your code to navigate here.
or put a container arround your pics and add the "android:onClick="navigateToNextActitivy"
there

elpatricko
- 488
- 5
- 17