Can't set method setResult in RecyclerAdapter

Can't set method setResult in RecyclerAdapter

setResult is not accessible inside MyViewHolder class becuase setResult is define inside Activity class

For accessing setResult from non Activity class pass Activity context in Adapter constructor when creating object of Adapter:

private Activity mActivity;
public MyViewHolder(View itemView,Activity mActivity) {
        super(itemView);
        /...your code here..
        this.mActivity=mActivity;
 }

use mActivity for accessing setResult inside onClick of Button


You can use setResult() and finish() by passing activity as a parameter to RecyclerAdapter, then access it using activity.setResult(), activity.finish()