Seb
Seb

Reputation: 227

Where and how to populate my tab using fragment

I'm working on an app' calling some webservice (that i code too) via asynchronous http request.

The async http request work just fine. I used it so far to log the user into the app and to get and present the result in an autocomplete field in the action bar. When the user select a result, it populate a navigation drawer with the data.

When i click on an element on this navigation drawer, it gets me to the relevant activity. This activity use tabs and fragment. The setup is ok, the tabs works fine.

I have to make another async http request when selecting an item in the navigation drawer to get the data that i have to show in the corresponding activity.

My question is : How and where should i make this http request to populate all the fragment of all my tabs ? Is it even possible to populate all fragment at a given time or do i have to populate the fragment of each tab when it gets selected ? In this case, i will have to store my data when i get the response and somehow call something that would populate my fragments.

As you can see, i'm a bit lost here !

Thx for any lead that would make me go in the right dircetion designing this part of my app'.

Upvotes: 3

Views: 284

Answers (1)

Michele La Ferla
Michele La Ferla

Reputation: 6884

I would personally create an http request upon populating each fragment. That way each fragment is updated when it is called from the navigation bar.

A great tutorial for creating http REST requests to a server is this one here followed by this

Hope this helps :)

Upvotes: 1

Related Questions