Do it in the bindView method and redraw the list view when the heavy task is
done. To make sure you're disabling and enabling the correct row, just make
sure the data that is bound through the adapter has a unique id associated
with it (or some other way of identifying any particular row uniquely) so
you can check for that id when the view is bound.



On Wed, Jan 21, 2009 at 3:36 AM, FENIX <jesus...@gmail.com> wrote:

>
> Hello guys! I really need your help here..
>
> I want to include one button inside each row in a ListActivity. When
> pressing one of these buttons it will be disabled and will perform a
> heavy task in the background (in a different thread to avoid screen
> blocking). After the action is completed the button will be enabled
> again and the row updated with some results obtained from that "heavy
> operation".
>
> Im filling my List with a custom SimpleCursorAdapter, its getView
> method calls super.getView and in the view (row) returned I access its
> button through findViewById and set my clicklistener (to disable it,
> and launch the heavy task in the background). Once this heavy task is
> finished I need a reference to this row view to find the button and re-
> enable it.
>
> SimpleCursorAdapter´s super.getView() reuses row views shown on screen
> to avoid creating many different rows instances, so when my "heavy
> task" is finished the row view reference i need to reenable its button
> may have been reused in a different row, so in the end I am modifying
> a button in a different row!
>
> I have tried different solutions, for example giving different ID to
> each row view (useless because it gets overwritten when the row view
> is reused...) Obviously creating a different row instance for each row
> whether its shown on screen or not isnt the best solution.
>
> I really have no clue on how to solve this .. thanks in advance
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to