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);
      }
    }
  }
コード例 #2
0
 /**
  * Returns the position if the currently selected GuidedAction.
  *
  * @return position The integer position of the currently selected action.
  */
 public int getSelectedActionPosition() {
   return mListView.getSelectedPosition();
 }