CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.2k stars 5.14k forks source link

4.0.1 中 无getViewByPosition方法 #3810

Open Small-World opened 9 months ago

Small-World commented 9 months ago

可恢复次方法吗,现在在回调里面用findViewHolderForLayoutPosition有点不够优雅

limuyang2 commented 8 months ago

你指的是getItem()方法吧

Small-World commented 8 months ago

这个方法: fun getViewByPosition(position: Int, @IdRes viewId: Int): View? { val recyclerView = recyclerViewOrNull ?: return null val viewHolder = recyclerView.findViewHolderForLayoutPosition(position) as BaseViewHolder? ?: return null return viewHolder.getViewOrNull(viewId) }

SaltedFish-Extreme commented 5 months ago

@limuyang2 新版的有方法可以获取到指定位置的view吗?😂

SaltedFish-Extreme commented 5 months ago

想要在setOnDebouncedItemClick里操作其他的view,找不到方法可以用😂

50kg commented 2 months ago
        RecyclerView.ViewHolder viewHolder = moneyDetailAdapter.getRecyclerView().findViewHolderForLayoutPosition(position);
        ImageView imageView = viewHolder.itemView.findViewById(R.id.image);
        //我也有这个需求,这样写解决了~