0

So if in

void ChildClick(object o, ExpandableListView.ChildClickEventArgs e)

o is the ExpandableListView that was clicked and e.Parent is also the ExpandableListView that was clicked and trying to create an instance of the LinearLayout in the Group for which the ChildClick took place by doing

ExpandableListView view = o;
LinearLayout group = (LinearLayout) view.GetChildAt(e.GroupPosition);

returns the LinearLayout in the nth position and not the GROUP layout in the nth position, how do I get an instance of the LinearLayout in the Group for which the child was clicked?

jmease
  • 2,507
  • 5
  • 49
  • 89

2 Answers2

0

I'm not really sure about where in the View tree you are trying to get too. But once you have a handel into that tree you can always call

view.getParent();

to go up a level. And

view.findViewById(R.id.yourlayoutname);

to go do several layers

Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
  • I thought that too, but whenever I get an instance of the LinearLayout of my child item by doing e.ClickedView and then doing e.ClickedView.Parent, it returns the ExpandableListView itself and not the Group LinearLayout for the clicked Child. – jmease Jun 27 '12 at 20:00
  • humm. Maybe you can try setting items can focus may help. http://stackoverflow.com/questions/2679948/focusable-edittext-inside-listview – Frank Sposaro Jun 27 '12 at 20:05
0

So this seems like going around my elbow to get to my ass instead of just having the parent of the child group actually be the parent group instead of the list view itself, but I've been able to get what I needed thusly:

ExpandableListView view = (ExpandableListView) o;
IExpandableListAdapter mAdapter = view.ExpandableListAdapter;
string s = mAdapter.GetGroup(e.GroupPosition).ToString(); //returns comma separated string with all my values from the group layout in the clicked item group position.
string[] items = s.Split(new [] {","}, StringSplitOptions.None);

Still open for suggestions if there is a way to get an instance of the actual group layout rather than just hoping the string in mAdapter always has the same number of comma delimited strings and the one I am after is always in the same spot. I want to get the actual LinearLayout in group position n so I can find the TextView by ID inside of it.

jmease
  • 2,507
  • 5
  • 49
  • 89