On Fri, Feb 5, 2010 at 10:44 AM, Gustavo <[email protected]> wrote:

> So where exactly should I get the parent of the button and how would I
> get the view's index in the adapter?
>

You would have to iterate over your collection of groups, and use
findViewById to actually get a hold of each button in each group, then add
an onClickListener to each. The onClickListener passes in the view that was
clicked, in this case that would be the button. Call getParent() on that to
get the parent view. Though note that depending on your layout that parent
may not necessarily be the group view.

Actually, not that I think about it, there may not be a good way to get the
index of the view even if you get it like this.

I'm not sure how Tag works..
>

The base View class has getTag() and setTag(), which let you get and set a
reference to an arbitrary object, respectively.
What you could do is as you're iterating through your list of groups to set
up the buttons, call setTag() on each button with the index of it's group.
When the button is clicked, in the onClickListener you call getTag() and you
have in the index.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to