Recyclerview Doesn't Appear In Fragment
i add a recyclerView to Fragment but it doesn't show any thing in side the fragment i found many questions for the same problem but actually i avoid those errors i Toast messages
Solution 1:
You should call adapter.notifyDataSetChanged()
every time you setting new list of data.
Take a look at the documentation.
A good solution would be to create setItems(items)
method inside adapter and call notifyDataSetChanged()
inside it.
Solution 2:
You need to change
adapter = newStoreListAdapter(v.getContext(), storesList);
storeRecyclerView.setAdapter(adapter);`
to
adapter = newStoreListAdapter(getActivity(), storesList);
storeRecyclerView.setAdapter(adapter);
Solution 3:
Code seems to be ok but i suspect there is a problem with Tablayout. In Main class [where u set the adapter to ViewPager] something link
ViewPager_Adapter_Class adapter= newViewPager_Adapter_Class (getChildFragmentManager());
I think mistake u made might be here :
use getChildFragmentManager() instead getFragmentManager()
ViewPager_Adapter_Class :
publicclassViewPager_Adapter_ClassextendsFragmentStatePagerAdapter {
publicAppLevelMainFragmentAdapter(FragmentManager fm) {
super(fm);
}
.................etc..,
}
Because Tablayout class might be fragment in which ur loading fragments in tablayout .If u use getFragmentManager()/getSupportFragmentManager which basically behaves like activity lifecycle so u need to use getChildFragmentManager(). This is what i suspect hope it will help you.
Post a Comment for "Recyclerview Doesn't Appear In Fragment"