title: How can I populate a ListView with contacts within a custom adapter class?
body: <p>I have a custom adapter. Within my <code>getView()</code>, I'm trying to populate <strong>"holder.contact"</strong> with a list of my contacts, but with no success. I do have this method of populating my <code>ListView</code> with contacts, but it disrupts the functionality of my <code>CheckBoxes</code>. This code is outside of my <code>CustomAdapter</code> class:</p>
  
  <pre><code>public void populateContactList() {
      // Build adapter with contact entries
      Cursor cursor = getContacts();
      String[] fields = new String[] {
              ContactsContract.Data.DISPLAY_NAME       
      };
  
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.contact_entry, cursor,
              fields, new int[] {R.id.contactEntryText});    
      lv.setAdapter(adapter);    
  } // END POPULATECONTACTLIST
  
  public Cursor getContacts()
  { 
      // Run query
      Uri uri = ContactsContract.Contacts.CONTENT_URI;
      String[] projection = new String[] {
              ContactsContract.Contacts._ID,
              ContactsContract.Contacts.DISPLAY_NAME        
      };
  
      String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
              (false ? "0" : "1") + "'";
      String[] selectionArgs = null;
      String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
  
      return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
  } // END GETCONTACTS 
  </code></pre>
  
  <p>But I'm trying to define it within here, but with no success (Custom Adapter class):</p>
  
  <pre><code>@Override
  public View getView(final int position, View convertView, ViewGroup parent)
  {
      View rowView = convertView;
      ViewHolder holder = null;
  
      if (rowView == null) {
          LayoutInflater inflater = (LayoutInflater)context.getSystemService(
                                             Context.LAYOUT_INFLATER_SERVICE);
          // HERE I AM INFLATING LISTVIEW LAYOUT.
          rowView = inflater.inflate(R.layout.contact_entry, null, false);
          holder = new ViewHolder();
          holder.photo = (ImageView) rowView.findViewById(R.id.iv_contactPic);
          holder.contact = (TextView) rowView.findViewById(R.id.contactEntryText);
          holder.tv = (TextView) rowView.findViewById(R.id.SMSCounttext);
          holder.cb = (CheckBox) rowView.findViewById(R.id.cb_contactHistoryChk);
  
  
          rowView.setTag(holder);
  
      } else {
          holder = (ViewHolder) rowView.getTag();
      }
  </code></pre>
  
  <p>Is there a way to apply my <strong>populateContactList()</strong> method within the <code>getView()</code>?</p>
  
  <p>My constructor looks like this. "elements" is already used by another textview:</p>
  
  <pre><code>public CustomAdapter(Context context, int type, ArrayList&lt;String&gt; elements){
      super(context, type, elements);
  </code></pre>