How to get the position of an image in a gridView ?

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

How to get the position of an image in a gridView ?

Postby Stam » Wed Nov 25, 2009 1:55 pm

Hi AndDev !

I'm trying to do a memory game with a GridView (or tell me if there is better solution than gridView...)

I set an OnItemClickListener, and I have the ImageView i've click, but how to know the position of the image ? Or can I set an ID of my ImageView in the Grid ?

Because I want to get the ID/position (something unique) to seach in a HashMap wich contains all my Image (to know what's the image, if it match with another image, etc...)

PS : Sry for my english, i'm french :x

Thanks a lot ;)
Stam
Junior Developer
Junior Developer
 
Posts: 22
Joined: Wed Nov 25, 2009 1:49 pm
Location: Lille, France

Top

Postby Stam » Wed Nov 25, 2009 3:18 pm

Ok, I Find ;)

in my GetView method of my ImageAdapter, i just add my ID like that :

imageView.setId(++id);

Then, in the onClick method when I get my ImageView, i can have my Id ;)
Stam
Junior Developer
Junior Developer
 
Posts: 22
Joined: Wed Nov 25, 2009 1:49 pm
Location: Lille, France

Re: How to get the position of an image in a gridView ?

Postby asbabu123 » Wed Jan 20, 2010 9:27 am

HI ,
I am a new developer for adroid. I am planning to develop memory game in android. I saw u r posts in this forum. Please give me ideas on this. How can i develop this game. give me a plan. If u succeded in this can u sent me the example code, that to if it is possible for u, other wise u give me the suggesstions on this.

Regards,
Suresh A
sureshalapati81@gmail.com
asbabu123
Freshman
Freshman
 
Posts: 5
Joined: Thu Oct 22, 2009 1:15 pm

Postby Stam » Fri Jan 22, 2010 5:47 pm

I send you my source next week, maybe I'll do a tutorial for this, it's a good programm for a beginner (I learn a lot by doing that memory game !)
Stam
Junior Developer
Junior Developer
 
Posts: 22
Joined: Wed Nov 25, 2009 1:49 pm
Location: Lille, France

Postby asbabu123 » Sat Jan 23, 2010 3:08 pm

Ya thanks for u r reply. up to that time i am trying to implement.

Thnks,
Suresh a
asbabu123
Freshman
Freshman
 
Posts: 5
Joined: Thu Oct 22, 2009 1:15 pm

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests