How to share RelativeLayout in item RecyclerView like image in Android Studio

I have Relativelayout in my items recyclerview,
i want share this item like image when on click button_share == shareThisScore();

please anybody help me .

enter image description here

Xml Item :

    <?xml version="1.0" encoding="utf-8"?>
        <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            app:cardCornerRadius="4dp"
            android:layout_marginBottom="2dp"
            >
        
            <RelativeLayout
                android:id="@+id/relativeLayoutLastScore"
                ..
                    >

                <TextView   .. />
                <androidx.cardview.widget.CardView ..>
                    <TextView ../>
        
                </androidx.cardview.widget.CardView ...>
                .
                .
                .
                .
                <ImageButton
                    android:id="@+id/imageButtonShare"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentBottom="true"
                    android:layout_marginEnd="15dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginBottom="7dp"
                    android:background="@drawable/custom_button"
                    android:src="@drawable/ic_share"/>
        
            </RelativeLayout>
        
        </androidx.cardview.widget.CardView>

onBindViewHolder in my adapter :

        public void onBindViewHolder(@NonNull ScoreViewHolder holder, int position) {
            ScoreItem currentItem = mScoreList.get(position);
    
            holder.mImageViewRank.setImageResource(currentItem.getImageViewRank());
            holder.mTextViewScore.setText(currentItem.getTextViewScore());
            .
            .
            .
    
            holder.mImageButtonShare.setOnClickListener(v -> {
    
                shareThisScore();
            } ); 
    
        }

Source: Android Studio Questions

LEAVE A COMMENT