Hi,

I am having trouble with setChecked(true) method of a CheckBox.

I have a ListView with Check Boxes as items in it. When the list
activity loads I need to check some of the checkboxes.
I have the positions of those items. I am able to get the text
associated with the checkboxes and also the state (checked/unchecked)
of the checkbox using

((CheckBox) tagsList.getChildAt(i)).getText().toString();

(tagsList is the ListView.)

I used

((CheckBox) tagsList.getChildAt(i)).setChecked(true);

to check the checkboxand is not working.

Here's the code..

myCursor is the cursor with the values from database.
ids is the ArrayList with checkbox Ids.


       private void markOldTags() {
                for (int i = 0; i < tagsList.getChildCount(); i++) {
                        myCursor.moveToPosition(i);
                        long buffer = myCursor.getLong(myCursor
                                        
.getColumnIndex(DatabaseAdapter.KEY_ID));
                        if (ids.contains(new Long(buffer))) {
                                showError(((CheckBox) 
tagsList.getChildAt(i)).getText().toString
());
                                ((CheckBox) 
tagsList.getChildAt(i)).setChecked(true);
                        }
                }

        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to