title: How to add Onclick listener to recycler view
body: <p>I am developing a simple notepad app first i used listView to show all the notes.But now I am using RecyclerView. While i am using listview i used OnItemClickListener to pass the Data to another activity for editing the note
  now i am confuse what to do in Recylerview</p>
  
  <p>For listView i am using this</p>
  
  <pre><code> listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              name = filenames.get(position).getName();
              note = filenames.get(position).getShorttext();
              Alert(); // this method is in main activity 
  
          }
      });*/  
  
  
    public void Alert()
     {
      final AlertDialog dialog;
      View mview = getLayoutInflater().inflate(R.layout.dialog_pass,null);
      final EditText mEdittext = (EditText) mview.findViewById(R.id.Epass);
      AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
      mBuilder.setView(mview);
      mBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              String col = mEdittext.getText().toString();
              String password = dBhelper.searchpass(col);
              if (col.equals(password)) {
                  Intent intent =  new Intent(MainActivity.this,Note2.class);
                  intent.putExtra("Name",name);
                  intent.putExtra("Note",note);
                  startActivity(intent);
              } else {
                  Toast temp = Toast.makeText(MainActivity.this, "Password does not match", Toast.LENGTH_SHORT);
                  temp.show();
              }
  
          }
      });
      mBuilder.setNegativeButton("Cancel",null);
      mBuilder.setCancelable(false);
      dialog = mBuilder.create();
      dialog.show();
  
       }
  </code></pre>
  
  <p>Now What Should i Do for Recycle View Please Help</p>
  
  <pre><code>  public class RecycleViewAdapter extends 
    RecyclerView.Adapter&lt;RecycleViewHolder&gt; {// Recyclerview will extend to
    private List&lt;FileName&gt; fileNames;
    private Context context;
  
    public RecycleViewAdapter(Context context,List&lt;FileName&gt; fileNames) {
      this.context = context;
      this.fileNames = fileNames;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>@Override
  public RecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      LayoutInflater mInflater = LayoutInflater.from(parent.getContext());
  
      ViewGroup mainGroup = (ViewGroup) mInflater.inflate(
              R.layout.grid_item, parent, false);
      RecycleViewHolder listHolder = new RecycleViewHolder(mainGroup);
      return listHolder;
  
  }
  
  @Override
  public void onBindViewHolder(RecycleViewHolder holder, final int position) {
      final FileName model = fileNames.get(position);
      RecycleViewHolder mainHolder = (RecycleViewHolder) holder;// holder
      mainHolder.title.setText(model.getName());
      mainHolder.note.setText(model.getShorttext());
  
  }
  
  @Override
  public int getItemCount() {
      return (null != fileNames ? fileNames.size() : 0);
    }
  </code></pre>