Sunday, October 25, 2009

[android-developers] Re: ListView with Streaming Content

On Oct 21, 10:02 pm, Streets Of Boston <flyingdutc...@gmail.com>
wrote:
> No need to call 'invalidate()' on your list-view.
> Call 'notifyDatasetChanged()' on your customer adapter instead,
> whenever you add or delete elements in your ArrayList or change the
> contents of existing elements in your ArrayList.

Hi,
I'm now trying this again, based on the SDK Notepadv3 example. This
uses a SimpleCursorAdapter.

I have a background Service that updates the database then calls a
callback in the main activity:

public void serviceUpdate() {
handler.post(new Runnable() {
public void run() {
// Break encapsulation to get at the SimpleCursorAdapter.
final SimpleCursorAdapter simpleCursorAdapter =
(SimpleCursorAdapter) getListView().getAdapter();
simpleCursorAdapter.notifyDataSetChanged();
getListView().setSelection(0);
}
});
}

It doesn't redraw the ListView though. It is only redrawn when another
Activity launches which covers it, and gets closed.

I'm now looking for the proper way to do it.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate