How to get Selected CardView position on OnClickListener android?
<p>I have list of contacts and i have show this list on RecyclerView using CardView.</p>

<p>List is showing perfectly But now I want to make clickable Card View. So that When I click on particular contact i will show details of particular contact.</p>

<p>When I click on particular CardView I Toast a message but can't find position of selected cardview and want to pass details of selected contact to another activity using intent.putExtra Method.</p>

<p>Code : </p>

<pre><code>  @Override
public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_layout, parent, false);
    ContactViewHolder contactViewHolder = new ContactViewHolder(view,ctx,contacts);
    return contactViewHolder;
}

@Override
public void onBindViewHolder(ContactViewHolder holder, int position) {
    Contact CON = contacts.get(position);
    holder.person_name.setText(CON.getName());
    holder.person_email.setText(CON.getEmail());
    holder.card_view.setOnClickListener(this);
}
@Override
public void onClick(View v) {
    Toast.makeText(this.ctx, "Hello", Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(this.ctx,task_detail.class);
    this.ctx.startActivity(intent);
}

@Override
public int getItemCount() {
    return contacts.size();
}

public static class ContactViewHolder extends RecyclerView.ViewHolder {
    TextView person_name, person_email;
    ArrayList&lt;Contact&gt; contacts = new ArrayList&lt;Contact&gt;();
    Context ctx;
    CardView card_view;

    public ContactViewHolder(View view, Context ctx ,ArrayList&lt;Contact&gt; contacts) {
        super(view);
        this.contacts=contacts;
        this.ctx = ctx;
        person_name = (TextView) view.findViewById(R.id.person_name);
        person_email = (TextView) view.findViewById(R.id.person_email);
        card_view =  (CardView) view.findViewById(R.id.card_view);
    }
}
</code></pre>