title: Recyclerview call contacts Android studio
body: <p>I have an android app where I have used RecyclerView that shows a list of contacts. Now what I want is that when selecting the contacts, call the indicated number.</p>
  
  <p>For now all it do is show the contacts, but when i click on it it calls, it does not do any action. I do not know how to get it to mark</p>
  
  <p>I tried with <code>onClick()</code> and with button item.But Unsuccessful</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.MyViewHolder&gt; {
  
      private static final String TAG = "RecyclerViewAdapter";
  
      Context mContext;
      List&lt;Contact&gt; mData;
      Dialog myDialog;
      Button button;
  
  
  
      public RecyclerViewAdapter(Context mContext, List&lt;Contact&gt; mData) {
          this.mContext = mContext;
          this.mData = mData;
      }
  
  
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
          View v ;
          v = LayoutInflater.from(mContext).inflate(R.layout.single_item_contact,parent,false);
          final MyViewHolder vHolder = new MyViewHolder(v);
  
          // Dialog ini
  
          myDialog = new Dialog(mContext);
          myDialog.setContentView(R.layout.dialog_contact);
          myDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  
  
  
  
  
          vHolder.item_contact.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                 // Toast.makeText(mContext,"Text Click item : "+String.valueOf(vHolder.getAdapterPosition()),Toast.LENGTH_SHORT).show();
  
  
                  TextView dialog_name_tv = (TextView) myDialog.findViewById(R.id.dialog_name_id);
                  TextView dialog_phone_tv = (TextView) myDialog.findViewById(R.id.dialog_phone_id);
                  ImageView dialog_contact_img = (ImageView)myDialog.findViewById(R.id.dialog_img);
                  dialog_name_tv.setText(mData.get(vHolder.getAdapterPosition()).getName());
                  dialog_phone_tv.setText(mData.get(vHolder.getAdapterPosition()).getPhone());
                  dialog_contact_img.setImageResource(mData.get(vHolder.getAdapterPosition()).getPhoto());
  
  
                  myDialog.show();
              }
          });
  
  
          return vHolder;
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, final int position) {
  
          holder.tv_name.setText(mData.get(position).getName());
          holder.tv_phone.setText(mData.get(position).getPhone());
          holder.img.setImageResource(mData.get(position).getPhoto());
  
  
  
      }
  
      @Override
      public int getItemCount() {
          return mData.size();
      }
  
      public static class MyViewHolder extends RecyclerView.ViewHolder {
  
          private LinearLayout item_contact;
          private TextView tv_name;
          private TextView tv_phone;
          private ImageView img;
  
          public MyViewHolder(View itemView) {
              super(itemView);
  
              item_contact = (LinearLayout) itemView.findViewById(R.id.contact_item_id);
              tv_name = (TextView) itemView.findViewById(R.id.name_contact);
              tv_phone = (TextView) itemView.findViewById(R.id.phone_contact);
              img = (ImageView) itemView.findViewById(R.id.img_contact);
  
          }
      }
  }
  </code></pre>
  
  <p>Aquí muestro mi XML de como tengo.
  help please</p>
  
  <pre><code>    &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="350dp"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="15dp"
          android:background="#232323"
          android:gravity="center_horizontal"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/dialog_name_id"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="90dp"
              android:text="Contact Name"
              android:textColor="@android:color/white"
              android:textSize="30sp"
              android:textStyle="bold" /&gt;
  
          &lt;TextView
              android:id="@+id/dialog_phone_id"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:layout_marginTop="5dp"
              android:text="Phone Number"
              android:textColor="@android:color/white"
              android:textSize="23sp" /&gt;
  
          &lt;Button
              android:id="@+id/dialog_btn_call"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="start"
              android:layout_marginTop="10dp"
              android:background="@android:color/white"
              android:drawableLeft="@drawable/dialog_call_black"
              android:drawablePadding="20dp"
              android:padding="20dp"
              android:text="Llamar"
              android:textAlignment="textStart"
              android:textSize="25dp" /&gt;
  
          &lt;Button
              android:id="@+id/dialog_btn_msg"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="start"
              android:background="@android:color/white"
              android:drawableLeft="@drawable/dialog_message_black"
              android:drawablePadding="20dp"
              android:padding="20dp"
              android:text="Mensaje"
              android:textAlignment="textStart"
              android:textSize="25dp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;ImageView
          android:id="@+id/dialog_img"
          android:layout_width="120dp"
          android:layout_height="120dp"
          android:src="@drawable/ic_contacts"
          android:padding="10dp"
          android:layout_centerHorizontal="true"
          android:layout_alignParentTop="true"
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>