Sunil kumar
Sunil kumar

Reputation: 337

ExpandableListView getGroupView friom child control

In an Expandablelistview, I want to update the one of the groupview image based on the selected control in the childview, how to accomplish this ?? basically i want like this

public View  getChildview(int groupPosition,final int childPosition, boolean isLastChild, View convertView,ViewGroup parent)
{

  View Groupview=parent.getChildAt(groupPosition); ///but gives null when if scrolling the expandablelist

}

EDIT Below Code works me

public View getGroupView(ExpandableListView listView, int groupPosition) {
  long packedPosition = ExpandableListView.getPackedPositionForGroup(groupPosition);
  int flatPosition = listView.getFlatListPosition(packedPosition);
  int first = listView.getFirstVisiblePosition();
  return listView.getChildAt(flatPosition - first);
}

Upvotes: 0

Views: 227

Answers (2)

dgzz
dgzz

Reputation: 3009

I suggest using OnChildClickListener and override onChildClick() and use this code in getting the parent view.

Upvotes: 1

jily
jily

Reputation: 344

getGroupView() – Returns view for the list group header
getChildView() – Returns view for list child item
So u must create/inflate view in getChildView method 

For more details:
http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/

Upvotes: 0

Related Questions