diff --git a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/fragments/FragmentExpandableSections.java b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/fragments/FragmentExpandableSections.java index 599d4eb8..9e8f2904 100644 --- a/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/fragments/FragmentExpandableSections.java +++ b/flexible-adapter-app/src/main/java/eu/davidea/samples/flexibleadapter/fragments/FragmentExpandableSections.java @@ -92,8 +92,9 @@ private void initializeRecyclerView(Bundle savedInstanceState) { Utils.getColorAccent(getActivity()), (MainActivity) getActivity()); // Experimenting NEW features (v5.0.0) mAdapter.setLongPressDragEnabled(true) //Enable long press to drag items - .setHandleDragEnabled(true); //Enable handle drag - //.setDisplayHeadersAtStartUp(true); //Show Headers at startUp: (not necessary if Headers are also Expandable) + .setHandleDragEnabled(true) //Enable handle drag + //.setDisplayHeadersAtStartUp(true); //Show Headers at startUp: (not necessary if Headers are also Expandable AND expanded at startup) + .setStickyHeaders(true); SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(true); diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java index 77a798df..a9e49962 100644 --- a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java +++ b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java @@ -346,12 +346,13 @@ public FlexibleAdapter expandItemsAtStartUp() { multiRange = true; while (position < getItemCount()) { T item = getItem(position); + if (!headersShown && isHeader(item) && !item.isHidden()) { + headersShown = true; + } if (isExpanded(item)) { expand(position, false, true); - if (!headersShown && isHeader(item) && !item.isHidden()) - headersShown = true; } - position++; + position++; //+1 Check also subItems with expanded = true } multiRange = false; setScrollAnimate(false);