void setHeadersVisiblity(boolean show) { mShow = show; final VerticalGridView listView = getVerticalGridView(); if (listView == null) { return; } final int count = listView.getChildCount(); final int visibility = mShow ? View.VISIBLE : View.INVISIBLE; // we should set visibility of selected view first so that it can // regain the focus from parent (which is FOCUS_AFTER_DESCENDANT) final int selectedPosition = listView.getSelectedPosition(); if (selectedPosition >= 0) { RecyclerView.ViewHolder vh = listView.findViewHolderForPosition(selectedPosition); if (vh != null) { vh.itemView.setVisibility(visibility); } } for (int i = 0; i < count; i++) { View child = listView.getChildAt(i); if (listView.getChildPosition(child) != selectedPosition) { child.setVisibility(visibility); } } }
void getHeaderViews(List<View> headers, List<Integer> positions) { final VerticalGridView listView = getVerticalGridView(); if (listView == null) { return; } final int count = listView.getChildCount(); for (int i = 0; i < count; i++) { View child = listView.getChildAt(i); headers.add(child); positions.add(listView.getChildViewHolder(child).getPosition()); } }