Ole Bille
Ole Bille

Reputation: 541

How do I make a list loader to reload from a detail Activity in Android

I have a ListFragment, which data is loaded by a SimpleCursorLoader(own imlementation; it loads with a curser and does not use URI).

When an item in the list is selected. I either start up a new activity (detail activity) or I show what is selected in the detail fragment next to the ListFragment. Depending on the screen size.

If the detail fragment is added to the ListActivity, I have figured out how to reload the list. I assign an interface to the ListActivity and call it from the detail fragment, when the change is happening. And in the list fragment I reload the list using getLoaderManager().restartLoader(0, null, this);

Now my problem is, if the detail activity is loaded, I don't have access to methods on the ListActivity. I could probably implement some observer pattern. But there must be a best practice for this.
How do you make a ListFragment reload the list, when a detail fragment has changed the data in the database.

Upvotes: 0

Views: 527

Answers (1)

Barak
Barak

Reputation: 16393

Try moving your list creation code to onResume. That way it runs on activity creation and every time you go away from the activity and come back.

Upvotes: 1

Related Questions