my RecyclerView do not call onCreateViewHolder, onBindViewHolder, therefore, does not appear nothing in recyclerview. I put logs for debugging, and no log is shown. What can
In my case i had this structure
<ScrollView>
<RelativeLayout>
<android.support.v7.widget.RecyclerView/>
</RelativeLayout>
</ScrollView>
i solved the problem remove Relative
<ScrollView>
<android.support.v7.widget.RecyclerView/>
</ScrollView>
Is kind of silly, but another thing that can block the calls to the methods is to declare the visibility of the view as GONE.
android:visibility="gone"
recyclerView.setVisibility(View.GONE);
Any of these will block the call of the methods in RecyclerView.Adapter
I hope it can help someone.
Might have been a different case but for me I just forgot to set the Layout Manager as follows:
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recycler.setLayoutManager(layoutManager);
Hope it helps :)
Its late but hope it will help somone. try either of the following:
first solution: make sure you haven't use this line unnecessarily
recyclerView.setHasFixedSize(true);
second solution:
make sure you set layout manager to recyclerView
recycler.setLayoutManager(new LinearLayoutManager(this));
third solution:
you getItemCount
returns 0, So RecyclerView
never tries to instantiate a view. Make it return something greater than 0
If RecyclerView gets put into a ScrollView, then during measure step its height is unspecified (because ScrollView allows any height) and gets equal to minimum height (as per implementation) which is apparently zero.
ref : android: RecyclerView inside a ScrollView
Solution : - put views in row of RecyclerViews - Calculate the size of the list items and set the height of the ListView programmatically http://vardhan-justlikethat.blogspot.com/2014/04/android-listview-inside-scrollview.html
In my Case I was using Fragment-> ViewPager and Tablayout -> Inside viewpagers item I used RecyclerView.
So Instead of calling ViewPagerAdapter(getChildFragmentManager()) , I was calling ViewPagerAdapter(getSupportFragmentManager()) , that is why any of my recycler adapter item is not getting called.
So proper way to set the ViewPagerAdapter within a fragment is
ViewPagerAdapter(getChildFragmentManager())