luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

How to change text style one of section #172

Closed idrisyagci closed 5 years ago

idrisyagci commented 5 years ago

Hello. I have two sections section 0 and section 1. I wanna customise section 1 textview as strikethrough. I tried to this like below but doesnt success. Is anyone help me to do this. Thank you.

    @Override
    public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
        final ItemViewHolder itemHolder = (ItemViewHolder) holder;

        itemHolder.tv.setText(list.get(position));
        itemHolder.imgItem.setImageResource(imgPlaceholderResId);

        if (sectionAdapter.getSection(1).getContentItemsTotal() > 0) {
            itemHolder.tv.setPaintFlags(itemHolder.tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        }
    }
idrisyagci commented 5 years ago

I solved this issue like below:

itemHolder.tv.setPaintFlags(itemHolder.getItemViewType() == 8 ? itemHolder.tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : Paint.LINEAR_TEXT_FLAG);