@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View contentView = super.onCreateView(inflater, container, savedInstanceState); mSampleAdapter.setChoiceMode(RecyclerAdapter.ChoiceMode.MULTIPLE_CHOICE); mSampleAdapter.setClickCallback( new ClickCallback() { @Override public void onItemClick(int position) { Sample sample = mSampleAdapter.getItemAt(position); Toast.makeText( getActivity(), "Item clicked : " + sample.getName() + " (" + mSampleAdapter.getSelectedItemViewCount() + " selected)", Toast.LENGTH_SHORT) .show(); } }); configureFragment(mRecyclerView, mSampleAdapter, new SampleSectionViewAdapter(getActivity())); setGestureCallback( ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT, new GestureCallback() { @Override public boolean onMove(int fromPosition, int toPosition) { Toast.makeText( getActivity(), "Item selected : " + mSampleAdapter.getSelectedItemViews(), Toast.LENGTH_SHORT) .show(); return false; } @Override public void onSwiped(int position, int direction) { Toast.makeText( getActivity(), "Item selected : " + mSampleAdapter.getSelectedItemViews(), Toast.LENGTH_SHORT) .show(); } }); List<Sample> samples = SampleAdapter.buildSamples(); Collections.sort( samples, new Comparator<Sample>() { @Override public int compare(Sample lhs, Sample rhs) { return lhs.getRate() - rhs.getRate(); } }); displayItems(samples); return contentView; }