Skip to content Skip to sidebar Skip to footer

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

Solution 1:

Make CategoryModel implements serializable. Put data in bundle using

Bundleargs=newBundle();
    args.putSerializable("key", data);
    fragment.setArguments(args);

Then, while getting data use:

if (getArguments() != null) {
        classObject = (ArrayList<CategoryModel>)  getArguments().getSerializable("key");
    }

Solution 2:

Make CategoryModel implement Parcelable then use bundle.putParcelableArrayList(key,list) and bundle.getParcelableArrayList(key)

Post a Comment for "How To Access Custom Arraylist In Fragment"