0

I m trying to set a "recyclerview" inside a fragment of a bottomnavigation.

 mExampleAdapter = new SearchItemAdapter(MainActivity.this, mExampleList);
                            mRecyclerView.setAdapter(mExampleAdapter);

Context works for a normal activity. But it does not in this fragment. I read the documentation which suggest using getActivity() for Context but it doesnt work ?.

 mExampleAdapter = new SearchItemAdapter(MainActivity.getActivity(), mExampleList);
                            mRecyclerView.setAdapter(mExampleAdapter);
Medy
  • 55
  • 1
  • 6

1 Answers1

0
mExampleAdapter = new SearchItemAdapter(getApplicationContext(), mExampleList);
                            mRecyclerView.setAdapter(mExampleAdapter);
Tung Tran
  • 2,885
  • 2
  • 17
  • 24