So, I guess I did what you told me to but the problem is that I'm not
getting that print on my log whenever I hit the button, I already
tried to set "clickable=true" on my xml but still nothing... what
could it be? am I doing it right?

SimpleExpandableListAdapter expListAdapter = new
SimpleExpandableListAdapter(
                                this,
                                // groupData describes the first-level entries
                                createGroupList(),
                                // Layout for the first-level entries
                                R.layout.group_row,
                                // Key in the groupData maps to display
                                new String[] { "texto1", "phone" },
                                // Data under "texto1" key goes into this 
TextView
                                new int[] { R.id.texto1 },
                                // childData describes second-level entries
                                createChildList(),
                                // Layout for second-level entries
                                R.layout.child_row,
                                // Keys in childData maps to display
                                new String[] { "texto2_1", "texto2_2", "phone2" 
},
                                // Data under the keys above go into these 
TextViews
                                new int[] { R.id.texto2_1, R.id.texto2_2, 
R.id.phone2 });

                // remove the indicator
                getExpandableListView().setGroupIndicator(null);
                setListAdapter(expListAdapter);

                int groupCount = getExpandableListAdapter().getGroupCount();
                for(int i = 0; i < groupCount; i++){
                        Log.i(TAG, "" + getExpandableListAdapter().getGroup(i));

                        LinearLayout groupLayout =
                                
(LinearLayout)getExpandableListAdapter().getGroupView(i, true,
null, null);
                        Button b = 
(Button)groupLayout.findViewById(R.id.button);
                        b.setOnClickListener(new OnClickListener() {

                                @Override
                                public void onClick(View v) {
                                        Log.i(TAG, "parent: " + v.getParent());
                                }
                        });
                }

Log:

02-05 17:49:36.288: INFO/myTag(16611): {texto1=Group 1, phone=55 11
56607209}
02-05 17:49:36.303: INFO/myTag(16611): {texto1=Group 2, phone=55 11
56607209}
02-05 17:49:36.311: INFO/myTag(16611): {texto1=Group 3, phone=55 11
56607209}
02-05 17:49:36.311: INFO/myTag(16611): {texto1=Group 4, phone=55 11
56607209}
02-05 17:49:36.327: INFO/myTag(16611): {texto1=Group 5, phone=55 11
56607209}
02-05 17:49:36.335: INFO/myTag(16611): {texto1=Group 6, phone=55 11
56607209}
02-05 17:49:36.335: INFO/myTag(16611): {texto1=Group 7, phone=55 11
56607209}
02-05 17:49:36.343: INFO/myTag(16611): {texto1=Group 8, phone=55 11
56607209}
02-05 17:49:36.358: INFO/myTag(16611): {texto1=Group 9, phone=55 11
56607209}
02-05 17:49:36.358: INFO/myTag(16611): {texto1=Group 10, phone=55 11
56607209}

I really appreciate your help, many thanks!

On Feb 5, 4:16 pm, TreKing <[email protected]> wrote:
> 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 
> deviceshttp://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