title: Recycler-view data binding on click of row
body: <p><strong>What I am doing</strong>: I have displayed the list view  using data binding</p>
  
  <p><strong>What I am trying to find</strong>: How to properly add a on click event and display a toast as student name</p>
  
  <p><strong>Student.java</strong></p>
  
  <pre><code>public class Student {
  
      private  String name;
      private  String email;
  
      public Student() {
      }
  
      public Student(String name, String email) {
          this.name = name;
          this.email = email;
      }
  
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
  
  }
  </code></pre>
  
  <p><strong>ActDemoListView.java</strong></p>
  
  <pre><code>public class ActDemoListView extends AppCompatActivity {
  
  
      private ActDemoListViewViewModel actDemoListViewViewModel;
      private ActDemoListViewBinding actDemoListViewBinding;
  
  
      private RecyclerView recyclerView;
      private AdptStudent adptStudent;
      private List&lt;Student&gt; studentList = new ArrayList&lt;&gt;();
  
      /************************************* Life Cycle Methods *************************************/
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          initOnCreate();
      }
      /************************************* Life Cycle Methods *************************************/
  
      /************************************* Init Methods *******************************************/
      /** Init OnCreate **/
      private void initOnCreate() {
          setContentView(R.layout.act_two_way_display_data);
          //Connect the view model to activity
          connectViewModel();
          //Bind the layout to activity
          bindLayoutToActivity();
  
          recyclerView = actDemoListViewBinding.recyclerList;
          adptStudent = new AdptStudent(studentList);
          RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
          recyclerView.setLayoutManager(mLayoutManager);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setAdapter(adptStudent);
  
          prepareMovieData();
      }
  
  
  
      /************************************* Init Methods *******************************************/
  
  
      private void connectViewModel() {
          actDemoListViewViewModel = ViewModelProviders.of(this).get(ActDemoListViewViewModel.class);
      }
  
      private void bindLayoutToActivity() {
          actDemoListViewBinding = DataBindingUtil.setContentView(this,R.layout.act_demo_list_view);
      }
  
      private void prepareMovieData() {
          Student movie = new Student("Shruthi", "user11@google.com");
          studentList.add(movie);
  
          movie = new Student("Shalvi", "user1@google.com");
          studentList.add(movie);
  
          movie = new Student("Pavan", "user2@google.com");
          studentList.add(movie);
  
          movie = new Student("Brijesh", "user3@google.com");
          studentList.add(movie);
  
          movie = new Student("Anudeep", "user4@google.com");
          studentList.add(movie);
  
          adptStudent.notifyDataSetChanged();
      }
  
  }
  </code></pre>
  
  <p><strong>AdptStudent.java</strong></p>
  
  <pre><code>public class AdptStudent extends RecyclerView.Adapter&lt;AdptStudent.MyViewHolder&gt; {
  
  
      private List&lt;Student&gt; studentsList = new ArrayList&lt;&gt;();
  
  
      public AdptStudent(List&lt;Student&gt; studentsList) {
          this.studentsList = studentsList;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          ListItemBinding listItemBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),R.layout.list_item, parent, false);
          return new MyViewHolder(listItemBinding);
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, int position) {
          Student student = studentsList.get(position);
          holder.listItemBinding.setStudent(student);
      }
  
      @Override
      public int getItemCount() {
          return studentsList.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
  
          private ListItemBinding listItemBinding;
  
          public MyViewHolder(ListItemBinding ListItemBinding) {
              super(ListItemBinding.getRoot());
              this.listItemBinding=ListItemBinding;
          }
      }
  
  
  }
  </code></pre>