angcyo / DslTabLayout

:hearts: Android界最万能的TabLayout(不仅仅是TabLayout), 支持任意类型的item, 支持Drawable类型的指示器,智能开启滚动,支持横竖向布局等
https://github.com/angcyo/DslAdapter
MIT License
1.55k stars 145 forks source link

DslTabLayout 点击事件 #63

Closed YQcharlse closed 2 years ago

YQcharlse commented 2 years ago

先是添加了所有item,然后动态的隐藏 GONE个别 item ,这时 item 的索引就会改变 怎样在点击事件时获取 之前没有隐藏时的 索引

angcyo commented 2 years ago

动态Gone Item之后, 请调用com.angcyo.tablayout.DslTabLayout#updateTabLayout 方法

YQcharlse commented 2 years ago

这样的话item索引也是会改变, 我想要的是item占位在索引上,索引不改变 这样的情况应该怎么做呢

angcyo commented 2 years ago

view.setTag自行保存

YQcharlse commented 2 years ago

嗯嗯好的那我知道了谢谢

YQcharlse commented 2 years ago

老哥,是否可以设置选中的view

angcyo commented 2 years ago

setCurrentItem

YQcharlse commented 2 years ago

我的意思是直接指定view

angcyo commented 2 years ago

通过View查找对应的Index, 然后setCurrenItem

YQcharlse commented 2 years ago

老哥怎么查找呀,没有找到方法呀

angcyo commented 2 years ago

getChildAt()

YQcharlse commented 2 years ago

哥,没明白呀,这个方法不是通过 index 查找 view吗?

angcyo commented 2 years ago
tabLayout.forEachIndexed { index, view ->
    if (view == xxx) {
        return index
    }
}
YQcharlse commented 2 years ago

哦哦谢谢老哥麻烦了,太感谢了