Working with Long Click Listener with recycler-android
<p>i am working on a notapad like android app project. i which i have implemented recycler.
My project contains NotedAdaper class that extends <code>RecyclerView.Adapter&lt;NotesAdapter.ViewHolder&gt;</code><br>
in that class using the below code i used click listener,   </p>

<pre><code>public class NotesAdapter extends RecyclerView.Adapter&lt;NotesAdapter.ViewHolder&gt; {

private List&lt;Notes&gt; mNotes;
private Context mContext;

public NotesAdapter(Context context, List&lt;Notes&gt; notes) {
    mNotes = notes;
    mContext = context;
}


@Override
public NotesAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Context context = parent.getContext();
    LayoutInflater inflater = LayoutInflater.from(context);

    // Inflate the custom layout
    View notesView = inflater.inflate(R.layout.items_notes, parent, false);

    // Return a new holder instance
    ViewHolder viewHolder = new ViewHolder(notesView);
    return viewHolder;
}


// Easy access to the context object in the recyclerview
private Context getContext() {
    return mContext;
}

@Override
public void onBindViewHolder(NotesAdapter.ViewHolder viewHolder, final int position) {

    // Get the data model based on position
    Notes notes = mNotes.get(position);

    // Set item views based on your views and data model
    TextView textView = viewHolder.preTitle;
    textView.setText(notes.getTitle());
    TextView textView1 = viewHolder.preText;
    textView1.setText(notes.getText());
    String color=notes.getColor();

    CardView preCard=viewHolder.preCard;
    preCard.setBackgroundColor(Color.parseColor(color));
    ImageView img = viewHolder.preImage;
    img.setVisibility(View.GONE);

    viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Notes notes = mNotes.get(position);
            Intent intent = new Intent(view.getContext(),EditNote.class);

            Bundle bundle = new Bundle();
            bundle.putSerializable("DATA",notes);
            intent.putExtras(bundle);
            getContext().startActivity(intent);

            Toast.makeText(getContext(), "Recycle Click" + position+"  ", Toast.LENGTH_SHORT).show();
        }
    });
}

// Returns the total count of items in the list
@Override
public int getItemCount() {
    return mNotes.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
    // Your holder should contain a member variable
    // for any view that will be set as you render a row
    public RobotoTextView preTitle, preText;
    public ImageView preImage;
    public CardView preCard;

    public ViewHolder(View itemView) {
        super(itemView);

        preTitle = (RobotoTextView) itemView.findViewById(R.id.preTitle);
        preText = (RobotoTextView) itemView.findViewById(R.id.preText);
        preImage=(ImageView) itemView.findViewById(R.id.preImage);
        preCard=(CardView) itemView.findViewById(R.id.preCard);

    }
}}   
</code></pre>

<p>And its absolutely working find. on clicking of a item in recycler, it retrieves the data using position of that item. and showing in another activity.
just like, suppose a activity shows the list of notes created by user. and clicking on any note, it shows the full content of that note.</p>

<p>but now i want to implement Long click listener on the item. and get the position.
so that, i used the following code ...</p>

<pre><code>viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Notes notes = mNotes.get(position);
                Toast.makeText(getContext(), "long Click" + position+"  ", Toast.LENGTH_SHORT).show();
                return false;
            }
        });  
</code></pre>

<p>so, its also working. 
but what i want is, on long click, it should only show that Toast.
but its not only showing the long click toast. but also recognising click listener and after showing the toast>> "Long click: ..." it executing the the code written for single click event.
n i dont want it.
both listeners should work separately. 
but why its executing single click after long click??? any idea???<br>
Am i making mistake anywhere?</p>