In my application I have the navigation broken down by the functional areas of the application so for example one area is the meetingmanagement. In an meeting I have several fields that are broken down into sections of the overall data entry form. To manage this I have set them up by section; however, I took the list items and put them in their own fragment thinking that I would need to only have one list displayed at a time (the requirements are targeting devices with 4.7″ screen on Gingerbread at the moment). My first question is; is it okay to host ListFragments and Fragments in a FragmentPager, or can a list be in a Fragment? (I included an example of how the UI currently adds the fragments for the pager, but I have not attempted to load anything in the lists yet.
private void initMeetingManager() {
List<Fragment> fragments = new Vector<Fragment>();
// Now add all of the meetingmanagement Fragment parts to the fragment list
fragments.add(Fragment.instantiate(this, MeetingGeneralFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingAttendeesFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingMessageTalkingPointsFragment.class.getName())); //Class Extends ListFragment to display Message Talking Points
fragments.add(Fragment.instantiate(this, MeetingIssueTalkingPointsFragment.class.getName())); //Class Extends ListFragment to display Issue Talking Points
fragments.add(Fragment.instantiate(this, MeetingObjectiveTalkingPointsFragment.class.getName())); //Class Extends ListFragment to display Objective Talking Points
fragments.add(Fragment.instantiate(this, MeetingAdditionalTalkingPointsFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingKnownAgreementsFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingPlanningObjectiveFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingAgreementsFragment.class.getName()));
fragments.add(Fragment.instantiate(this, MeetingAssessmentFragment.class.getName()));
fragments.add(Fragment.instantiate(this, AttachmentFragment.class.getName()));
// add the array the the pager adapter
this.mPagerAdapter = new AppPagerAdapter(super.getSupportFragmentManager(), fragments);
ViewPager pager = (ViewPager) super.findViewById(R.id.viewpager);
pager.setAdapter(this.mPagerAdapter);
}
Any comments are greatly appreciated.
Maybe late but better then never i thought:
Is it okay to host ListFragments and Fragments in a FragmentPager, or can a list be in a Fragment?
Yes and Yes, but: If youre holding a lot of Fragments whith a certain complexity you should consider using the FragmentStatePagerAdapter instead of the FragmentPagerAdapter.
I thought i throw in this recommendation, if your CustomAdapter extends the StatePager i never said anything!
Happy Coding!