I am converting ListView of my app to RecyclerView. On ListView, it was very easy to implement OnClickListener but in RecyclerView, we have to do it in adapter. I want to op
To add on to the approved answer: if you still get an error you might need to replace this line;
FragmentManager manager = ((Activity)context).getFragmentManager();
With this
FragmentManager manager = ((AppCompatActivity)context).getSupportFragmentManager();
For me this was because I was using the support.v4.app.FragmentManager instead of the regular fragmentmanager
Still get an error?
As one comment below pointed out, this might throw a java.lang.ClassCastException: and log ... cannot be cast to android.support.v7.app.AppCompatActivity (check comments for details)
Their fix was to use this instead (I haven't tested it but it worked for them):
((AppCompatActivity)activity).getSupportFragmentManager()