Wednesday, July 27, 2011

[android-developers] Re: changing listview content in separate thread issue

Abishek & gjs,

thanks for your suggestions. Abishek, are you sure it's necessary to
do what you suggested. Isn't the whole point of calling
getMainLooper() so that you can set the thread for the handler? So
assuming that you're right, do you know if the constructor for the
IntentService is executed in the calling thread or in the new thread?
If so I guess that's where I'd initialize the Handler. Anyway, I'm
not so sure that this will work because I don't have access to the
listview in this service and from what I've been reading, the whole
problem is that you need to immediately call notifyDataSetChanged on
the listview as soon as you add/delete/change the content of the
listview.

If anybody has any ideas on how to deal with this situation where the
content of a listview is changing in another thread where I don't have
access to the listview and need to notify the listview that the
content has changed I'd appreciate your input.

On Jul 26, 6:09 pm, Abhishek Akhani <abhishek.akh...@gmail.com> wrote:
> Your handler object should be created in main UI thread...
> So write this line in Main UI thread
>
>   Handler handler = new
> Handler(getMainLooper());
>
> and post the message from another thread....

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