problem with Checkboxes inside ListView using BaseAdapter

by droid_gal » Sat, 02 Apr 2011 10:47:13 GMT


Sponsored Links
 Dear all,

I have a problem with my adapter that extends BaseAdapter
That is to inflate the listview's rows with a text view and a
checkbox.
The size of the listview is of 20 after binding and have to scroll to
see all the items.
When I checked a checkbox, says it's from the 1st row, it's also
checked the 11th checkbox automatically.
When I unchecked the 1st one, then the 11th also is unchecked.
I tried for different rows and I found out that it automatically
checks/unchecks the checkbox with difference of 10 from the checked/
unchecked one.

This is the layout xml file content for individual row:
<FrameLayout
  xmlns:android=" http://schemas.android.com/apk/res/android" ;
  android:layout_width="match_parent"
  android:layout_height="match_parent"

  >
  <TextView android:id="@+id/tvRow"
        android:textSize="16sp"
        android:textStyle="bold"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:gravity="center_vertical|center_horizontal"/>

        <CheckBox android:id="@+id/chkRow"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_gravity="right"
                android:background="@null"
        />
  </FrameLayout>

Thanks in advance for any input to this issue.

-- 



Re: problem with Checkboxes inside ListView using BaseAdapter

by Justin Anderson » Sat, 02 Apr 2011 13:33:29 GMT


 You are suffering from a case of view recycling.  You have to keep track of
the checked views on your own and set the checked state of the checkbox in
your adapter's getView() method.

If you search Google for Android View Recycling you should be able to find
several examples of how to do this.

Thanks,
Justin Anderson
MagouyaWare Developer
 http://sites.google.com/site/magouyaware 






-- 


Sponsored Links


Re: problem with Checkboxes inside ListView using BaseAdapter

by Mary Aone » Thu, 12 May 2011 08:59:30 GMT


 @Justin Anderson: Thanks. I 'd already solved the issue and it was the same
way you mentioned.





-- 



Other Threads

1. Call a service hosted in a windows service from Android

Hello!

I hosted my service WCF (.net) using a windows service,  i can access to the
service from any browser but when i tried to call it from android it doesn't
respond. it works fine before the hosting procedure (i used host client by
default on Visual Studio).
The url that i try to attempt is http://10.0.2.2/...... from android
emulator, and installed my webservice in the same local machine(endpoints
address http://localhost.....).

Thx for any help !!

-- 

2. How to tell which permission are required?

Hi, 

I have a problem with an application, that refuses to start, and I think it 
may be because of missing permission(s). Is there any way to tell which 
permissions are required by an application in order to run?

Thanks

-- 

3. Re[2]: Galaxy S

4. Android Display through Composite Output

5. (WTA) Motodroid no Sound

6. What about this problem?

7. OOT WTA: member Id-Android domisili Karawang