Q: How to solve issue with ViewPager using with tablayout (design support library)? I am using latest android design tablayout with viewpager, I have three tabs with a common fragment displaying grids of images using grid view. All tabs have different set of images. But data is not displaying properly in 1 and 2 fragment on swipe. Here is my code:
public class ChannelPagerAdapter extends FragmentStatePagerAdapter {
private final List<Fragment> mFragments = new ArrayList<>();
private final List<String> mFragmentTitles = new ArrayList<>();
private ChannelsModel data;

public ChannelPagerAdapter(FragmentManager fm,  ChannelsModel data) {
    super(fm);
    this.data = data;
}

public void addFragment(Fragment fragment, String title) {
    mFragments.add(fragment);
    mFragmentTitles.add(title);
}

@Override
public Fragment getItem(int position) {
    ChannelsFragment fragment = (ChannelsFragment) mFragments.get(position);
    Bundle bundle = new Bundle();

    if(position == 0) {
        fragment.setData(data);
    }
    else if(position == 1) {
        fragment.setData(data);
    }
    else if(position == 2) {
        fragment.setData(data);

    }
    bundle.putInt("position", position);
    fragment.setArguments(bundle);
    return fragment;
}

@Override
public int getCount() {
    return mFragments.size();
}

@Override
public CharSequence getPageTitle(int position) {
    return mFragmentTitles.get(position);
}}

Here is the code for fragment:
public class ChannelsFragment extends Fragment implements ChannelGridAdapter.OnItemClickListener{
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
private ChannelGridAdapter mAdapter;
private List<? extends VehicalModel> vehicalData = new ArrayList<>();
private ChannelsModel data;
public ChannelsFragment() {
    // Required empty public constructor
}

public static final String ARG_PAGE = "ARG_PAGE";
private int mPage;

public void setData(ChannelsModel data) {
    this.data = data;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int position = getArguments().getInt("position");
    if(position == 0)
        vehicalData = new ArrayList<>(data.getCar());
    else if(position == 1)
        vehicalData = new ArrayList<>(data.getBike());
    else if(position == 2)
        vehicalData = new ArrayList<>(data.getHmv());
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View rootView =  inflater.inflate(R.layout.fragment_channels, container, false);
    setRetainInstance(true);

    mRecyclerView = (RecyclerView)rootView.findViewById(R.id.channelGrid);
    mRecyclerView.setHasFixedSize(true);

    // The number of Columns
    mLayoutManager = new GridLayoutManager(getContext(), 2);

    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new ChannelGridAdapter(getContext(), vehicalData);
    mAdapter.setOnItemClickListener(this);

    mRecyclerView.setAdapter(mAdapter);
    return rootView;
}

@Override
public void onItemClick(Object object, int position) {
    startActivity(new Intent(getActivity(), ChannelListActivity.class));
}
}

Plz help me to figure out the problem.
