Currently I have an activity that setContentView
of a layout which contains a listfragment. Basically it loads a listview.
My actionbar contains a spinner which lets me load in different lists. I could just load the List Objects in the background, and update the one fragment's adapter when the user switches to those lists using the spinner options. But this would not retain the position that the user has scrolled to.
I want to mess around with loading multiple listfragments, and when the user chooses a different spinner option, a fragment transaction happens which displays one of the other listfragments associated with that particular list.
How would I do this, and how would I modify my host activity?
Examples where I have seen FragmentTransaction
used involved creating all of the fragments in the onCreate
method of the host activity, and no fragments in the XML. Right now I have one fragment in the XML and need to create two more ListFragments that are practically identical.
Insight appreciated