I am developing an android app that will have a recyclerview in fragment but am having errors implementing it in the code.
Error "linealayoutmanager (android.content.context) in linealayoutmanager cannot be applied to (packagename.FragmentA)"
See my code below
public class FragmentA extends Fragment {
private ListView listView;
private MyAdapter myAdapter;
Context context;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_a, container, false);
//Part of cardview code starts here
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerList);
LinearLayoutManager llm = new LinearLayoutManager(this);//ERROR HERE
llm.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(llm);
recyclerView.setAdapter(new MyRecyclerAdapter(generatePalettes()));
recyclerView.addOnItemTouchListener(
new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
switch( position )
{
case 0: Intent myIntent = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 1: Intent myIntent1 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 2: Intent myIntent2 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 3: Intent myIntent3 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 4: Intent myIntent4 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 5: Intent myIntent5 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 6: Intent myIntent6 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 7: Intent myIntent7 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 8: Intent myIntent8 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
case 9: Intent myIntent9 = new Intent(FragmentA.this.getActivity(), AboutFounder.class);
break;
}
}
})
);
//Ends here
return rootView;
}
//Remaining part of CardView Starts Here
private ArrayList<palette> generatePalettes() {
ArrayList<palette> palettes = new ArrayList<palette>();
palettes.add(new Palette("PUNCH", R.mipmap.ic_launcher));
palettes.add(new Palette("TRIBUNE", R.mipmap.ic_launcher));
palettes.add(new Palette("DAILYPOST", R.mipmap.ic_launcher));
palettes.add(new Palette("THE SUN", R.mipmap.ic_launcher));
palettes.add(new Palette("THE GUARDIAN", R.mipmap.ic_launcher));
palettes.add(new Palette("THE NATION", R.mipmap.ic_launcher));
palettes.add(new Palette("THISDAY LIVE", R.mipmap.ic_launcher));
palettes.add(new Palette("PREMIUM TIMES", R.mipmap.ic_launcher));
palettes.add(new Palette("SAHARA REPORTS", R.mipmap.ic_launcher));
palettes.add(new Palette("VANGUARD", R.mipmap.ic_launcher));
return palettes;
}
}
Kindly help