title: Programatically access specific rows in List of CheckedTextView's - Android
body: <p>is it possible to programatically access specific rows in a list of CheckedTextViews to change the state of their textboxes?</p>
  
  <p>my program has a listview which has several CheckedTextViews which the user can press to toggle state.</p>
  
  <p>I want to save the state of the checkboxes when the user leaves the activity, so I have in my onPause method:</p>
  
  <pre><code>public void onPause(){
           super.onPause();
           SparseBooleanArray positions;
           positions = listView.getCheckedItemPositions();
           ListAdapter items = listView.getAdapter();
           int j = items.getCount();
  
           ArrayList&lt;Long&gt; ids = new ArrayList&lt;Long&gt;();
           for (int k =0; k &lt; j;k++){
               if(positions.get(k)==true){
                   ids.add(items.getItemId(k));   
               }
           } 
           this.application.getServicesHelper().open();
           this.application.getServicesHelper().storeServices(ids,visit_id);
           this.application.getServicesHelper().close();
       }
  </code></pre>
  
  <p>which very simply iterates the list view, adds the checked items to an ArrayList and then saves that list of ids to the database. </p>
  
  <p>My problem lise in trying to reset the list once a user goes back to that activity.</p>
  
  <p>so far in my onStart method, I recall the checked items from the database, but I do not know how to march the ids returned to the listview elements. can I do something like:</p>
  
  <p><code>listView.getElementById(id_from_database).setChecked</code>?</p>
  
  <p>I know I cant use getElementById but I have it here to show what I mean</p>
  
  <p>Thanks in advance</p>
  
  <p>Kevin</p>