This has to do with the fact that ListView recycles views.  View
Romain Guy's Google I/O talk about ListView when it comes out.  It is
really good and explains exactly why you're seeing this happen.

On Apr 30, 10:20 am, David <[email protected]> wrote:
> Hey,
>
> I am facing a very mysterious Problem. I am using a ListView with
> CheckBoxes that can be clicked to select people.
> The row layout is the following:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout
>   xmlns:android="http://schemas.android.com/apk/res/android";
>   android:orientation="horizontal"
>   android:layout_width="fill_parent"
>   android:layout_height="wrap_content">
>         <CheckBox
>                 android:focusable="false"
>                 android:onClick="onSelectPerson"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:gravity="center_vertical"
>             android:layout_marginRight="5dip"
> android:layout_marginLeft="5dip"/>
>         <TextView
>                 android:id="@+id/person_name"
>                 android:text="test"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:gravity="center_vertical"
>                 android:textSize="18dip" android:layout_marginLeft="5dip"/>
> </LinearLayout>
>
> As long as the amount of rows doesen't exceed the screen size (-> no
> scrolling) everything works just fine.
> But as soon as I have more rows then the screen size (-> some rows are
> hidden and have to be scrolled to).
> I have a very mysterious phenomenon:
>
> If I check the top row and scroll down some of the previously hidden
> rows are randomly checked too. If I scroll up again, again some of the
> before hidden rows are randomly vhecked (the CheckBox I clicked in
> first place may or may not still be checked).
> Also the registered onSelectPerson callback is only called for the
> CheckBoxes I really click. The other CheckBoxes just change their
> state to "checked" without calling the callback method.
> I have the same phenomenom on the Archos IT 5 and the Nexus One.
>
> This must have something to do with the ListView implementation but I
> can't quite figure out what the problem is.
> Can anyone help?
>
> Best Regards
>
> David
>
> --
> 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 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
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