Note that there are some explanatory texts on larger screens.

plurals
  1. POEvery seventh box checked with CheckBoxes in ListView
    primarykey
    data
    text
    <p>I have a ListView that has 649 entries. Each View in the list has two LinearLayouts, an ImageView, a few TextViews, and a CheckBox. I currently have code to go through all the CheckBoxes and count them, and more code to figure out which ones are checked so I can use them. However, whenever I check one of the CheckBoxes, every seventh CheckBox above and below it magically become checked as well. The method to count the checked boxes returns the number I actually checked, but the method to get the indices of all the checked boxes just returns the first x checked, regardless of whether I checked them or the ones 7 away from them. For example, if I check number 21, the method returns index 3. I have included some of the relevant code segments: The layout code for each View in the list:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p> </p> <pre><code>&lt;TextView android:id="@+id/id" android:layout_width="50dp" android:layout_height="50dp" android:textSize="20sp"/&gt; &lt;LinearLayout android:layout_width="180dp" android:layout_height="50dp" android:orientation="vertical"&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/name"/&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:textColor="#777777" android:id="@+id/type"/&gt; &lt;/LinearLayout&gt; &lt;CheckBox android:layout_gravity="right|center_horizontal" android:id="@+id/check" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:focusableInTouchMode="false"/&gt; </code></pre> <p></p> <p>Check counting method:</p> <pre><code> public int[] whichAreChecked() //TODO: this should work. { int listItemCount = ChooserList.getChildCount(); ArrayList&lt;Integer&gt; ints=new ArrayList&lt;Integer&gt;(); for(int i=0; i&lt;listItemCount; i++) { CheckBox cbox = (CheckBox) ((View)ChooserList.getChildAt(i)).findViewById(R.id.check); if(cbox.isChecked()) ints.add(i); } Log.e("durr", ""+ints.size()); int[] result=new int[ints.size()]; for(int i=0; i&lt;result.length; i++) result[i]=ints.get(i); return result; } </code></pre> <p>Check counting method:</p> <pre><code> public int countChecks() { int checked=0; int listItemCount = ChooserList.getChildCount(); for(int i=0; i&lt;listItemCount; i++) { CheckBox cbox = (CheckBox) ((View)ChooserList.getChildAt(i)).findViewById(R.id.check); if(cbox.isChecked()) checked++; } Log.e("countChecks()", ""+checked); return checked; } </code></pre> <p>If I can add any extra info, please ask!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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