Android recyclerview expand not working for first item

118 Views Asked by At

I am working on the expandable recyclerview in android. Please see my below code on adapter class. It's working fine for all items except the first item. Please help me on this.

@Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
     //   holder.txt_draft_vin.setText(movieList.get(position).getTitle());

        final boolean isExpanded = position == mExpandedPosition;
        holder.expandableLayout.setVisibility(isExpanded ? View.VISIBLE:View.GONE);
        holder.expandableLayout.setActivated(isExpanded);
        holder.img_caret.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               
                    mExpandedPosition = isExpanded ? -1 : position;
                    notifyItemChanged(position);
                    notifyItemChanged(mExpandedPosition);
                    notifyDataSetChanged();
                
            }
        });


    }
0

There are 0 best solutions below