At least it's strange to me...

My goal is to display a list of items each with a checkbox and when
the user selects some and hits an OK button, I save those items to a
database.

I'm starting slow and currently trying to display a list of checkboxes
and be able to check various items.  The list of items is pretty long
(scrolls off the screen) and I've noticed that when I select an item,
every item about ten places away also gets checked.

What's going on with my list?  Do I need to create a custom
ListAdapter to get the correct behavior?

Thanks
-matthew

My ListActivity class:
public class ItemList extends ListActivity {

        @Override
        protected void onCreate (Bundle savedInstanceState) {
                super.onCreate (savedInstanceState);
                setContentView (R.layout.itemlist);

                Button okButton = (Button)findViewById (R.id.itemlist_ok);
                okButton.setOnClickListener (new View.OnClickListener() {
                        @Override
                        public void onClick (View v) {
                                setResult (RESULT_OK);
                                finish ();
                        }
                });

                fillList ();
        }


        private void fillList ()
        {
                ArrayList <String> items = new ArrayList <String> ();

                // ... fill list...

                ArrayAdapter <String> adapter = new ArrayAdapter <String> (this,
R.layout.list_element, comics);
                setListAdapter (adapter);
        }
}


list_element.xml contains:


<?xml version="1.0" encoding="utf-8"?>
<CheckBox id="@+id/listelement"
          xmlns:android="http://schemas.android.com/apk/res/android";
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/>


and itemlist.xml contains:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:orientation="vertical">

        <ListView android:id="@+id/android:list"
                          android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:choiceMode="multipleChoice"/>



        <Button android:id="@+id/itemlist_ok"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="OK"/>

</LinearLayout>

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