OnLongItemClick in RecyclerView

You can add listeners in your custom adapter implementation. It will be something like: public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> { public interface OnItemClickListener { public void onItemClicked(int position); } public interface OnItemLongClickListener { public boolean onItemLongClicked(int position); } private Fragment mFragment; public static class ViewHolder extends RecyclerView.ViewHolder { public View v; public ViewHolder(View v) { … Read more

how to implement a long click listener on a listview

You have to set setOnItemLongClickListener() in the ListView: lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) { // TODO Auto-generated method stub Log.v(“long clicked”,”pos: ” + pos); return true; } }); The XML for each item in the list (should you use a custom XML) must have android:longClickable=”true” as … Read more