I'm creating an adapter for a RecyclerView; currently creating an onClickListener to the items within the RecyclerView; I wish to go back to a fragment which I can't seem to do, so I have tried to add onBackPressed() with super.onBackPressed in the method as the fragment is on the previous page; I have called this in the onClickListener and it doesn't seem to work, any ideas how I can fix this?
Code is as follows:
public class MyViewHolder extends RecyclerView.ViewHolder { TextView text1, text2, text3;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
// This onClick doesn't accept onBackPressed() or popBackStack(), however I need to get this to the previous page which is a fragment.
}
});