title: Why am I getting java.lang.ClassCastException on checkbox.getTag()?
body: <p>Can you tell me why my code isn't working? It used to be working fine and now that I'm changing over from <code>listView</code> to <code>recyclerView</code> I'm getting: </p>
  
  <pre><code>java.lang.ClassCastException: java.lang.Integer cannot be cast to com.app.SelectPhoneContact
  </code></pre>
  
  <p>Whichever checkboxes are in my <code>recyclerView</code>, it's supposed to <code>toast</code> the corresponding numbers of those ones that are checked. </p>
  
  <pre><code> Button btnGetItem = (Button) findViewById(R.id.btnGetItem);
          btnGetItem.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  //loop through the Matching Contacts
                  int count = MatchingContactsAsArrayList.size();
  
                  for (int i = 0; i &lt; count; i++) {
                      //for each Matching Contacts row in the recyclerview
                      LinearLayout itemLayout = (LinearLayout) recyclerView.getChildAt(i); // Find by under LinearLayout
                      //for each Matching Contacts checkbox
                      CheckBox checkbox = (CheckBox) itemLayout.findViewById(R.id.checkBoxContact);
                      //get other data related to the selected contact - name and number
                      SelectPhoneContact data = (SelectPhoneContact) checkbox.getTag();
  
                      //if that checkbox is checked, then get the phone number
                      if (checkbox.isChecked()) {
  
                          Toast.makeText(NewContact.this, data.getPhone(), Toast.LENGTH_LONG).show();
                      }
                  }
              }
          });
  </code></pre>
  
  <p>The error is on line 303, which is:</p>
  
  <pre><code>SelectPhoneContact data = (SelectPhoneContact) checkbox.getTag();
  </code></pre>