Saturday, June 25, 2011

Re: [android-developers] Re: Update activity UI from service using observer pattern

It seems like problem is somehow related to fact that I'm trying to
tie listener with controls of activity in adapter.

I there any other way to attach listener code to controls in
particular row of listview instead of used by me?

2011/6/23 Vadim Khondar <vadim.khondar@gmail.com>:
> Hello!
>
> In my case listeners are registered within adapter (so any changes are
> still going through method, part of which was in my previous email).
>
> I've already had an idea to manually implement things that I thought
> AsyncTask does for me, e.g. creating looper, handler, runnable etc.
> So if you tell it works for you, maybe the cause lays within AsyncTask
> implementation (haven't investigated it yet).
>
> Anyways, thanks for sane response.
>
> 2011/6/22 Kostya Vasilyev <kmansoft@gmail.com>:
>>
>>
>> 2011/6/22 Vadim Khondar <vadim.khondar@gmail.com>
>>>
>>> But code that sets ProgressBar value and text of TextView within this
>>> method does not cause screen redraw.
>>
>>
>> Then there is a problem with how you update the UI.
>>
>> Since list view recycles item views, you may not be updating the view you
>> think you are updating.
>>
>> In general, I can tell you this architecture works (and there is a lot of
>> envidence besides just my saying so - e.g. the Market application with its
>> download progress updates).
>>
>> In my code, the callbacks are all pure Java (not Intents), state changes
>> originate from worker threads and are marshalled to the UI thread within the
>> service by using a Handler.
>>
>> The code that updates {Expandable}ListView iterates its children until it
>> finds a child layout that matches the current state change, calls
>> findViewById to get the relevant views, and calls regular UI changing
>> methods to reflect the state change (setText, setProgress, setVisibility,
>> etc.)
>>
>> The key methods are: getFirstVisiblePosition and getLastVisiblePosition in
>> AdapterView.
>>
>> -- Kostya
>>
>
> --
> Best regards,
>  Vadim
>
> God, grant me the serenity to accept the things I cannot change,
> courage to change the things I can,
> and wisdom always to tell the difference.
> Rainhold Niebuhr
>

--
Best regards,
 Vadim

God, grant me the serenity to accept the things I cannot change,
courage to change the things I can,
and wisdom always to tell the difference.
Rainhold Niebuhr

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment