Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad ActivityList with pre-selected rows
    primarykey
    data
    text
    <p>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".</p> <p>This is the code I am using to mark a row as checked</p> <pre><code>for (int i = 0; i &lt; sourceList.length; i++) { DataSource d = sourceList[i]; view.getChildAt(i).getClass().toString()); CheckedTextView checkView = (CheckedTextView)view.getChildAt(i); checkView.setChecked(Boolean.parseBoolean(d.enabled)); } </code></pre> <p>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.</p> <p>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?</p> <p>Thank you!</p> <p>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()</p> <pre><code>@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; } </code></pre> <p>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</p> <pre><code>checkView.setChecked(true); </code></pre> <p>That did not work for me either. Do you have any more ideas on what I might be doing wrong?</p> <p>Thanks again!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload