Way to check CheckedTextView via Adapter as ListView gets populated
<p>I have a class that extends ListActivity and contains a ListView that is populated via an ArrayList of objects and a custom Adapter I have created that subclasses ArrayAdapter.</p>

<p><strong>I would like one field of the object to reference whether the object row should be checked or unchecked.</strong></p>

<p><strong>Then when the ListView gets populated some of the rows will be pre-selected (checked)</strong></p>

<p>I have overriden ArrayAdapter.getView() so that I can populate my layout via an object.</p>

<p>I thought that it would be here that I would set the row to be checked or not - but I cannot come up with a solution - any ideas?</p>

<p>here is my getView() code:</p>

<pre><code>@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.contactedit_onerow, null);
    }

    ContactVO mObject = items.get(position);
    if (mObject != null) {
        CheckedTextView nameV = (CheckedTextView) convertView.findViewById(R.id.rowText1);
        TextView phoneV = (TextView) convertView.findViewById(R.id.rowText2);
        TextView emailV = (TextView) convertView.findViewById(R.id.rowText3);
        TextView headerV = (TextView) convertView.findViewById(R.id.alphaHeader);

        if (alphaIndexer.get(mObject.name.substring(0, 1).toUpperCase()) == position ) {
            headerV.setText(mObject.name.substring(0,1));
            headerV.setVisibility(View.VISIBLE);
        } else {
            headerV.setText("");
            headerV.setVisibility(View.GONE);
        }

        nameV.setText(mObject.name);
        phoneV.setText("Phone: " + mObject.phone);
        emailV.setText("Email: " + (mObject.email != null ? mObject.email : ""));

                    // THE FOLLOWING LINE UNCOMMENTED DOES NOTHING 
                    // (any suggestions to make it work)
                    // nameV.setChecked(true);
    }

    return convertView;
}
</code></pre>

<p>Thanks in advance!</p>
