I am developing an app based off fragments. A lot of the content of these fragments is collected from a database utilizing an AsyncTask. As such I'm trying to externalize the 'getting data' class so it can be reused. My fragment is as follows:

So.. as far as I understand, this all essentially calls back to the onLoadComplete method contained within my fragment. I can then set the list adapter with the data but how to I load it into a view...? Also.. yes it works.. but what is actually being listened for here? THere is no click for example. Thanks
–
Thomas ClowesNov 20 '12 at 16:28

@ThomasClowes That interface abstracts the connection between the AsyncTask and the component that will use the data retrieved by the task. The code basically says: (from the fragment's perspective) I'm creating this task to get data and I will register myself as a listener(by implementing the onLoadComplete method) so I can use that retrieved data. The AsyncTask will get the data as usual and when it finishes it will see that there are interested components for that data(the mListener is not null) so it forwards the data to that registered listener.
–
LuksprogNov 20 '12 at 16:59

@ThomasClowes With this code, the AsyncTask doesn't know anything about who uses that data(and it doesn't care). The listeners could be your list fragment, an activity, a normal fragment etc, anyone who implements the onLoadComplete method of the interface(and registers as a listener with the task) as that is the only thing the task knows. I don't understand at what are you referring when talking about load it into a view.
–
LuksprogNov 20 '12 at 17:02

Awesome. Thanks very much ! The final aspect of my query is as follows: So I have gotten the data from the AsyncTask to my registered listener, but how do I know load my list view. If my data were a static array I would simply inflate it in my onCreateView method of the fragment. THanks
–
Thomas ClowesNov 20 '12 at 17:09

As I expected i was being stupid. It was an error in my LoadDataFromURL which meant the view was not loading. Thanks for your help. Am i correct in thinking setListAdapter runs (per se) in whichever view is currently set?
–
Thomas ClowesNov 20 '12 at 18:12