@Override public boolean onGroupClick(ExpandableListView expandableListView, View view, int position, long l) { resetStreamSearch(); String streamName = ((TextView) view.findViewById(R.id.name)).getText().toString(); doNarrowToLastRead(streamName); if (!isTablet()) drawerLayout.openDrawer(GravityCompat.START); if (previousClick != -1 && expandableListView.getCount() > previousClick) { expandableListView.collapseGroup(previousClick); } expandableListView.expandGroup(position); previousClick = position; onNarrowFillSendBoxStream(streamName, "", false); return true; } });
@Override public void onBackPressed() { ExpandableListView elv; boolean groupsCollapsed = false; for (int i=0; i<elv.getCount(); ++i) { if (elv.isGroupExpanded(i)) { elv.collapseGroup(i); groupsCollapsed = true; } } // If no groups collapsed, call the default back button if (!groupsCollapsed) { super.onBackPressed(); } }
height += list.getDividerHeight() * (list.getCount() - 1); Log.i("height", "" + height); return height;
private static String buildAdapterViewItemIndex(View child, ViewGroup group) { int index = ((AdapterView) group).getPositionForView(child); // ExpandableListView if (group instanceof ExpandableListView) { StringBuilder element = new StringBuilder(); String exListIndicator = ""; ExpandableListView _group = (ExpandableListView) group; long l = _group.getExpandableListPosition(index); int groupIndex; if (ExpandableListView.getPackedPositionType(l) == ExpandableListView.PACKED_POSITION_TYPE_NULL) { if (index < _group.getHeaderViewsCount()) { exListIndicator = "[header:" + index + "]";// header } else { groupIndex = index - (_group.getCount() - _group.getFooterViewsCount()); exListIndicator = "[footer:" + groupIndex + "]";// footer } } else { groupIndex = ExpandableListView.getPackedPositionGroup(l); int childIndex = ExpandableListView.getPackedPositionChild(l); if (childIndex != -1) { exListIndicator = "[group:" + groupIndex + ",child:" + childIndex + "]";// group/child } else { exListIndicator = "[group:" + groupIndex + "]";// group } } Log.d("ExpandableListViewItem", "@index = " + index + ", @exListIndicator = " + exListIndicator); return exListIndicator; } return "[" + index + "]"; }
private void showExpandData(){ cartExpandAdapter=new CartExpandAdapter(this,cartExpandablelistview,cartInfo.getData()); cartExpandablelistview.setAdapter(cartExpandAdapter); int intgroupCount = cartExpandablelistview.getCount(); for (int i=0; i<intgroupCount; i++)