I have a main activity with a ViewPager. I am trying to populate the ViewPager using an Adapter.
This is my Fragment Class.
public class ClassListFragment extends Fragment {
private List<item_timetable_class> _classList;
public ClassListFragment() {
}
public ClassListFragment SetClassList (List<item_timetable_class> classList) {
    ClassListFragment fragment = new ClassListFragment();
    fragment._classList = classList;
    return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // some code here
    //In this line I am getting _classList = Null        
      class_card_adapter adapter = new class_card_adapter(_classList, getContext());
    // some code here
    }
}
This is how I am calling the Fragment. Please note that Just after creating a new ClassListFragment Object, I am calling SetClassList so that the internal variable _classList is Set.
    // Set up the ViewPager with the sections adapter.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    for (int i = 0; i < weekday_list.size(); i++) {
        ClassListFragment newFragment = new ClassListFragment();
        newFragment.SetClassList(classCardList);
        mSectionsPagerAdapter.addFragment(newFragment, weekday_list.get(i));
        i++;
    }
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
Unfortunately, the onCreateView method is being executed when the below line is being executed in the main activity.
mViewPager.setAdapter(mSectionsPagerAdapter);
And at that time, the List _classList is coming as null.
What could be the problem and How can I resolve the issue?
 
     
     
     
    