Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:16:55+00:00 2026-05-20T18:16:55+00:00

I have a list of custom objects that I am loading into an ActivityList

  • 0

I have a list of custom objects that I am loading into an ActivityList that allows multiple selections and displays the checkbox on the right side. Those custom objects contain a field named “enabled”. When I load the data I want to scroll through the list of objects and check the checkbox for each row that represents an object that has the enable field marked true. Currently I have all of the records loading into the ActivityList as I want but I can not make any of the rows “checked” even though objects are marked as “enabled”.

This is the code I am using to mark a row as checked

for (int i = 0; i < sourceList.length; i++) {
    DataSource d = sourceList[i];
    view.getChildAt(i).getClass().toString());
    CheckedTextView checkView = (CheckedTextView)view.getChildAt(i);
    checkView.setChecked(Boolean.parseBoolean(d.enabled));
}

I have put this code directly after calling setListAdapter and I have put it in the onContentChanged() function. However, in both places the rows are not displayed yet so the view.getChildAt(i) returns null so obviously the row does not get checked.

Can anyone tell me where I can put this code so that it will be executed after all rows have been added and displayed on the screen?

Thank you!

Originally I did not have a custom Adapter I was just using ArrayAdapter. In order to override the getView() method I created a custom Adapter and extended ArrayAdapter. I am still allowing the ArrayAdapter class to do most of the work but I am overriding getView(). Here is my code for getView()

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    convertView = super.getView(position, convertView, parent);

    if (convertView.getClass() == CheckedTextView.class){
        CheckedTextView checkView = (CheckedTextView)convertView;
        DataSource d = getItem(position);
        checkView.setText(d.getName());
        checkView.setChecked(Boolean.parseBoolean(d.enabled));
    }

    return convertView;
}

Even with this code none of the check boxes are being checked. The DataSource’s name field is being set as the text but the setChecked() method does not seem to be working for me. I also tried hard coding that to be

checkView.setChecked(true);

That did not work for me either. Do you have any more ideas on what I might be doing wrong?

Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:16:56+00:00Added an answer on May 20, 2026 at 6:16 pm

    Can you show your adapter code? The place to call setChecked is in your getView code in your adapter. It will be something like:

    @Override
    getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(
                R.layout.my_list_row, parent, false);
        }
        CheckedTextView checkView = (CheckedTextView)
            convertView.findViewById(R.id.check_view);
        DataSource d = sourceList[i];
        checkView.setChecked(Boolean.parseBoolean(d.enabled));
        return convertView;
    }
    

    ListView doesn’t really expose its children via getChildAt. The intended interface is via constructing and populating rows in getView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datagrid that displays a list of custom objects. This list contains
I have a Generic List of objects that I've bound to a custom control.
I have list view with custom row layout (list_row.xml) that contains CheckBox element: <TableLayout
I have a list of custom objects that I use as the commandName object
I have a generic list of custom objects and would like to reduce that
I have a model that contains an IEnumerable of a list of custom objects.
I have a gridview that is databound to a list of custom objects. On
I have a list of custom objects List and I would like to update
I have a list of custom objects. These objects have 2 datetime properties on
I have one custom action (add) and two custom objects (favorites list) and (tv

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.