Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.6.1-x 版本,在 RecyclerView 中保留展开/收起状态不起作用 #83

Open
24suixinsuoyu opened this issue Jun 6, 2023 · 0 comments

Comments

@24suixinsuoyu
Copy link

如题

版本是:v1.6.1-x

如下,按照源码注释加了必要的逻辑,但不起作用。(Demo 中是可以保留状态的,好奇用的哪个版本,或者我哪里写错了?)

data class CommentWrapBean(var comment: String?) : ExpandableStatusFix {
    private var status: StatusType? = null

    override fun getStatus(): StatusType? {
        return status
    }

    override fun setStatus(status: StatusType) {
        this.status = status
    }
}
val commentView = holder.getView<ExpandableTextView>(R.id.etv_comment)
val commentWrapBean = CommentWrapBean(item.content)
commentView.bind(commentWrapBean)
commentView.setContent(commentWrapBean.comment)

源码注释:

/**
 * @date: on 2018/9/20
 * @author: cretin
 * @email: [email protected]
 * @desc: 如果你需要在滑动的时候保持之前的展开或者收起的状态
 * 则
 * 一、实现 ExpandableStatusFix
 * 二、在你的model中定义一个
 * private StatusType status;
 * 三、实现对应的方法,将你刚刚定义的status返回,
 * 四、并在给ExpandableTextView设置内容之前,调用bind方法
 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant