0

I am trying to collapse all sections in recyclerview except one ( currently selected).. I can collapse all items successfully.. but I want to reverse the arrow direction in headerholder.. I Using the library as https://github.com/luizgrp/SectionedRecyclerViewAdapter.. while reversing the arrow it is giving null pointer exception for headerholders out of window ( not visible in present screen)..

{
    for (int i = 0; i < deviceInfoList.size(); i++) {
        ExpandableDeviceSection section = (ExpandableDeviceSection) sectionAdapter.getSection(deviceInfoList.get(i).getdName());
        if (section.expanded && !section.dName.equals(dName)) {
            section.expanded = false;

            HeaderViewHolder headerViewHolder1=(HeaderViewHolder)recyclerView.findViewHolderForAdapterPosition(sectionAdapter.getHeaderPositionInAdapter(section.dName));
                            //getting null for sectionHeader which is not available.
            if(headerViewHolder1!=null)
                headerViewHolder1.imgArrow.setImageResource(section.expanded ? R.drawable.ic_expand_less : R.drawable.ic_expand_more);
        }
    }
//                    sectionAdapter.notifyDataSetChanged();
}

here is my all collapse code in onclick listener.. I hope this clarifies.. let me know if anything else required..

novrox
  • 1
  • 1
  • You should show a [mcve]. That link will be dead in an internet moment. –  Nov 14 '18 at 17:27

1 Answers1

0

Problem solved.. forgot to set image view (imagearrow) in onbindheaderview holder.. No need to set it in for loop now .

novrox
  • 1
  • 1