We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我看鸡你太美还用的最开始的1.0.0版本,可能没看到你发布的版本,直接复制readme的,我用他自定义的子类一堆方法报错,后来用你的玩安卓自定义的CollectView就好了
还有感觉revealLayout.setOnCheckedChangeListener监听的回调方法好像没啥用,还是你定义的点击回调接口更有用,毕竟一般都是在RecyclerView中使用,一般会有默认选中的项目,还有点击后选中的逻辑判断,我把你的自定义子类改成用科特林实现的了,一些简单的逻辑判断也写在里面了
revealLayout.setOnCheckedChangeListener
class CollectView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : RevealLayout(context, attrs, defStyleAttr) { private lateinit var mOnClickListener: OnClickListener override fun initAttr(attrs: AttributeSet) { super.initAttr(attrs) setCheckWithExpand(true) setUncheckWithExpand(false) setAnimDuration(400) setAllowRevert(false) } override fun getCheckedLayoutId() = R.layout.view_reveal_like_checked override fun getUncheckedLayoutId() = R.layout.view_reveal_like_unchecked fun setOnClickListener(onClickListener: OnClickListener) { mOnClickListener = onClickListener setOnClickListener { if (AppConfig.UserName.isNotEmpty()) { //登陆过直接走点击事件回调 mOnClickListener.onClick(this@CollectView) context.vibration() //震动一下 } else { //否则弹吐司并且不给选中 ToastUtils.show(R.string.please_login) isChecked = false } } } interface OnClickListener { fun onClick(v: CollectView) } }
在adapter的onItemViewHolderCreated中使用
onItemViewHolderCreated
override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) { super.onItemViewHolderCreated(viewHolder, viewType) viewHolder.getView<CollectView>(R.id.item_article_collect).setOnClickListener(object : CollectView.OnClickListener { //收藏控件点击事件回调 override fun onClick(v: CollectView) { if (v.isChecked) { ...... } } else { ...... } } } }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我看鸡你太美还用的最开始的1.0.0版本,可能没看到你发布的版本,直接复制readme的,我用他自定义的子类一堆方法报错,后来用你的玩安卓自定义的CollectView就好了
还有感觉
revealLayout.setOnCheckedChangeListener
监听的回调方法好像没啥用,还是你定义的点击回调接口更有用,毕竟一般都是在RecyclerView中使用,一般会有默认选中的项目,还有点击后选中的逻辑判断,我把你的自定义子类改成用科特林实现的了,一些简单的逻辑判断也写在里面了在adapter的
onItemViewHolderCreated
中使用The text was updated successfully, but these errors were encountered: