Code example for ExpandableListView

Methods: getChildAtgetExpandableListPositionisGroupExpanded, getFirstVisiblePosition, pointToPosition

0
			int visibleItemCount, int totalItemCount) {
		 
		ExpandableListView listView = (ExpandableListView)view;
		int npos = view.pointToPosition(1,0);
		if(npos != AdapterView.INVALID_POSITION){
			long pos = listView.getExpandableListPosition(npos);
			int childPos = ExpandableListView.getPackedPositionChild(pos);
			int groupPos = ExpandableListView.getPackedPositionGroup(pos);
			if(childPos == AdapterView.INVALID_POSITION){
				View groupView = listView.getChildAt(npos - listView.getFirstVisiblePosition());
				indicatorGroupHeight = groupView.getHeight();
				if(indicatorGroupHeight == 0){
					return; 
				} 
			} 
			if(groupPos != indicatorGroupId){				
				mAdapter.getGroupView(groupPos, 
						listView.isGroupExpanded(groupPos), indicatorGroup.getChildAt(0), null);				
				indicatorGroupId = groupPos;				
				mAdapter.hideGroup(groupPos);				
				mAdapter.notifyDataSetChanged();
				Log.e(TAG,PRE + "move to new group" + groupPos);
			} 
		} 
		int imageHeight = indicatorGroupHeight;
		int nEndPos = listView.pointToPosition(1,indicatorGroupHeight-1);
		if(nEndPos != AdapterView.INVALID_POSITION){
			long pos = listView.getExpandableListPosition(nEndPos);
			int groupPos = ExpandableListView.getPackedPositionGroup(pos);
			if(groupPos != indicatorGroupId){
				//group 
				View viewNext = listView.getChildAt(nEndPos-listView.getFirstVisiblePosition());
				imageHeight = viewNext.getTop();
				Log.e(TAG,PRE + "START UP MOVE:" + imageHeight);
			} 
		} 
		// show group 
		MarginLayoutParams layoutParams = (MarginLayoutParams)indicatorGroup.getLayoutParams();
		 
		layoutParams.topMargin = imageHeight-indicatorGroupHeight;
		indicatorGroup.setLayoutParams(layoutParams);
		int firstVisible = listView.getFirstVisiblePosition();
		if(firstVisible != AdapterView.INVALID_POSITION){			
			int firstGroup = ExpandableListView.getPackedPositionGroup(
					listView.getExpandableListPosition(firstVisible));
			if(firstGroup == indicatorGroupId &&
					listView.isGroupExpanded(indicatorGroupId) == false){
				indicatorGroup.setVisibility(View.INVISIBLE);
				Log.e(TAG,PRE + "indicator group hide");
			}else{ 
				indicatorGroup.setVisibility(View.VISIBLE);
				Log.e(TAG,PRE + "indicator group show");