> 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.
Replace the current contents of your Runnable with a call to requery() on
the underlying Cursor. That will trigger an update of the
SimpleCursorAdapter and the corresponding ListView.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---