Q:

How to access custom arraylist in fragment

I have tablayout in my app,and i want to set recyclerview in tablayout fragment.if i set static String array it is working fine.but i dont know how can i access custom arraylist in fragment to set data in my recyclerview.following is my code can any one help me with that
public class CategoriesActivity extends AppCompatActivity{

    private Header myview;
    private ArrayList<SubcategoryModel> subct;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.categoris_activity);

        ArrayList<CategoryModel> filelist =  (ArrayList<CategoryModel>)getIntent().getSerializableExtra("categorylist");

        System.out.println("Category list size"+filelist.size());
        myview = (Header) findViewById(R.id.categorisactivity_headerView);
        myview.setActivity(this);
        TabLayout tabLayout = (TabLayout) findViewById(R.id.cat_tab_layout);

        for(int i = 0; i < filelist.size(); i++){

             subct=filelist.get(i).getItems();
            for(int j=0;j<subct.size();j++)
            {

            }
            System.out.println("SubCategory list size"+subct.size());
        }

        for(int i = 0; i < filelist.size(); i++){

            tabLayout.addTab(tabLayout.newTab().setText(filelist.get(i).getCategory_typename()));

            ArrayList<SubcategoryModel> subct=filelist.get(i).getItems();
            for(int j=0;j<subct.size();j++)
            {

            }

        }
        Bundle bundleObject = new Bundle();
        bundleObject.putSerializable("key", filelist);
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

        final ViewPager viewPager = (ViewPager) findViewById(R.id.categories_pager);

        CategoriesAdapter  mPagerAdapter = new CategoriesAdapter(getSupportFragmentManager(),tabLayout.getTabCount());
        viewPager.setAdapter(mPagerAdapter);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
        tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewPager.setCurrentItem(tab.getPosition());

            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

    }

   public class CategoriesAdapter extends FragmentStatePagerAdapter {
        ArrayList<CategoryModel> catlist;
       int numoftabs;

        public CategoriesAdapter(FragmentManager fm, int numoftabs) {
            super(fm);
            this.numoftabs = numoftabs;
        }

        @Override
        public Fragment getItem(int position) {

            Log.v("adapter", "getitem" + String.valueOf(position));
            return FirstFragment.create(position);
        }

        @Override
        public int getCount() {
            return numoftabs;
        }
    }

}

Fragment
public class FirstFragment extends Fragment {
    // Store instance variables
    public static final String ARG_PAGE = "page";
    private int mPageNumber;
    private Context mContext;
    private int Cimage;
    private ArrayList<SubcategoryModel> subcatlist;
    private RecyclerView rcylervw;
    private ArrayList<CategoryModel> filelist;

    public static FirstFragment create(int pageNumber){
        FirstFragment fragment = new FirstFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PAGE, pageNumber);
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPageNumber = getArguments().getInt(ARG_PAGE);

        // image uri get uri of image that saved in directory of app
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        ViewGroup rootView = (ViewGroup) inflater
                .inflate(R.layout.test, container, false);

        // Get the Bundle Object
        Bundle bundleObject = getActivity().getIntent().getExtras();

        // Get ArrayList Bundle
        ArrayList<CategoryModel> classObject = (ArrayList<CategoryModel>) bundleObject.getSerializable("key");

        System.out.println("Frag Category list size"+classObject.size());

        rcylervw=(RecyclerView)rootView.findViewById(R.id.subcategory_recycler_view);
        rcylervw.setHasFixedSize(true);
        MyAdapter adapter = new MyAdapter(new String[]{"test one", "test two", "test three", "test four", "test five" , "test six" , "test seven"});
        rcylervw.setAdapter(adapter);

        LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        rcylervw.setLayoutManager(llm);

        return rootView;
    }

getting NPE here
 // Get the Bundle Object
            Bundle bundleObject = getActivity().getIntent().getExtras();

            // Get ArrayList Bundle
            ArrayList<CategoryModel> classObject = (ArrayList<CategoryModel>) bundleObject.getSerializable("key");

A:

Make CategoryModel implements serializable. Put data in bundle using 
    Bundle args = new Bundle();
    args.putSerializable("key", data);
    fragment.setArguments(args);

Then, while getting data use:
    if (getArguments() != null) {
        classObject = (ArrayList<CategoryModel>)  getArguments().getSerializable("key");
    }

