ExpansionPanel icon indicating copy to clipboard operation
ExpansionPanel copied to clipboard

Add an option to not set click listener on the header by default

Open Peterragheb opened this issue 6 years ago • 1 comments

I wanted to keep track of the expanded item position. Using the default expansion listener didn't work. So I had to write my own onClickListener which was not possible because you set it by default in the header class. I had to create my custom header to remove the clickListener and add my own clicklistener in the recyclerview adapter. Can you also please make it that when calling .expand() or .collapse() with false as the parameter to reset the indicator without animation too.

        if (isExpanded)
            holder.binding.expansionLayout.expand(false);
        else
            holder.binding.expansionLayout.collapse(false);
        expansionsCollection.add(holder.binding.expansionLayout);
        holder.binding.ehHeader.setActivated(isExpanded);
        holder.binding.ehHeader.setHeaderRotationCollapsed(0);
        holder.binding.ehHeader.setHeaderRotationExpanded(180);
        holder.binding.ehHeader.setOnClickListener(v -> {
            if (isEnabled){
                mExpandedPosition = isExpanded ? -1: position;
                holder.binding.expansionLayout.toggle(true);
            }
        });

Peterragheb avatar Nov 15 '19 22:11 Peterragheb

I also was looking for a way to set a custom click handler on the header. I ended up setting it in .doOnAttach because the default is set in onAttach and mine would be set after.

mattcrwi avatar Jun 19 '20 17:06 mattcrwi