Android: how to access the node in position (from outside the adapter)

I have a recycler view adapter. Thus, he has 3 species. Just every view has an ImageView. When the user clicks on the image (1 of 3), he creates a new intention to use the application for photos and returns it to the caller when this is done. The caller (the asset created by RecyclerView and its adapter) processes onActivityResult. From there, I need to set the thumbnail, which was made in the specified intent, to the correspondingly selected ImageView.

Question. In my activity, how can I find out which imageView (from the available 3) to change? My activity only knows about the position that the element clicked in the recycler view adapter.

Is it possible to somehow get a link to a specific image in the adapter using only the position? So something like this: from activity: adapter.getImageView(position)

EDIT: So I decided: I tracked all ImageViews in the adapter and saved their ref in ArrayList in `onBindViewHolder. so now i can just use adapter.getImageView (position)

+7
android android-recyclerview android-viewholder
source share
2 answers

I believe that you can set the OnClickListener for your ImageView (or for your row view) in the adapter. Just shoot from there.

-one
source share

Just add a method to the adapter to return the link to the image in the right place. The adapter contains a list of u objects that are transferred to it, so you can control them as you wish.

-one
source share

All Articles