getActivity in Activity

android, android-recyclerview, onclicklistener

Solution

You have declared your code inside of an `Activity`. Therefore you can simply use `this` to reference the `Activity` you are in.

mRecyclerView.setAdapter(mAdapter);
mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, this));

Problem

I'm having trouble with getActivity() in Activity. It says can't resolve method getActivity(). I'm using it to make onClick in recyclerView. Here is my code ``` mRecyclerView.setAdapter(mAdapter); mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), this)); ``` What should I change getActivity with? Thanks in advance

Original source