How To Get Child View From Recyclerview?
Solution 1:
Use recyclerView.findViewHolderForLayoutPosition(position)
or
reyclerView.findViewHolderForAdapterPosition(position)
to get the viewholder for postion. Then you can access any child from your viewholder.
Checkout Recyclerview
Solution 2:
RecyclerView.ViewHolderholder= recycleView.findViewHolderForAdapterPosition(position);
ImageViewimageView= holder.itemView.findViewById(R.id.iv_product);
This is a supplement to @Ravi Teja's answer. You can get the viewHolder from the recyclerView using position of the particular item, then get a particular view from the viewHolder as shown above
Solution 3:
You can use RecyclerView's LayoutManager for it.
Viewview= layoutManager.findViewByPosition(position)
Solution 4:
Hope this helps someone: I was getting null pointer exceptions with:
- recyclerView.findViewHolderForAdapterPosition
- recyclerView.findViewHolderForItemId
- layoutManager.findViewByPosition.
The reason was that there is a slight delay for the viewholder to be created. I found the solution here: https://stackoverflow.com/a/33414430/7952427
Solution 5:
I post an answer because which is really complex to findviews() from RecyclerView.
@Joe: After spending 4hours found one answer. Which gives me the proper view of the index.
mAdapter is adapter of RecyclerView
View v = recyclerView.findViewHolderForItemId(mAdapter.getItemId(index/position)).itemView;
Now just access your views by:
v.findViewById(R.id.edittext)
OR any id.
Post a Comment for "How To Get Child View From Recyclerview?"