@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_programme_list, container, false); FragmentActivity context = getActivity(); rv = (RecyclerView) view.findViewById(R.id.rec_view_prog); LinearLayoutManager llm = new LinearLayoutManager(context); rv.setLayoutManager(llm); // Init programme list adapter programmes = Programme.listAll(Programme.class); programmeAdapter = new ProgrammeAdapter(programmes); // Set adapter to page view rv.setAdapter(programmeAdapter); programmeAdapter.SetOnItemClickListener( new ProgrammeAdapter.OnItemClickListener() { public void onItemClick(View v, int position) { // Load programme detail fragment on item click Programme selectedProgramme = programmes.get(position); mListener.onProgrammeSelected(selectedProgramme.getId()); } }); return view; }
protected void syncData() { programmeAdapter.notifyDataSetChanged(); }