Skip to content Skip to sidebar Skip to footer

How To Get Other Views In Same Viewholder At Same Position As The Onclicked View (use In A Recyclerview Adapter)

I have a RecyclerView in my app that displays a row containing pictures and photographs downloaded from the internet. There is a photo and a button on screen. When the user clicks

Solution 1:

Another way is implement onBindViewHolder(ViewHolder holder, final int position) in your Adapter

This method already have position as a third argument.

LIKE

@OverridepublicvoidonBindViewHolder(final ViewHolder holder, finalint position) {

     holder.mImageView2.setOnClickListener(newView.OnClickListener() {
        @OverridepublicvoidonClick(View v) {

        }
    });

Solution 2:

Try getAdapterPosition method of the ViewHolder. it will return the position of the Holder in the Recycler/Adapter

Post a Comment for "How To Get Other Views In Same Viewholder At Same Position As The Onclicked View (use In A Recyclerview Adapter)"