Skip to content
Advertisement

Recycler view shows only first item, even though onBindViewHolder and onCreateViewHolder run for all of them

As the title says;

At first, onBindViewHolder only ran for the first item. Looking at questions and answers on this site indeed revealed that I needed to set the wrapping view’s height to wrap_content. This did fix the first issue and now logcat shows that all methods run properly; However, still, only the first item is displayed.

Why might this happen, and how might I fix it?

MatchHolder (contained in MatchAdapter):

JavaScript

MatchAdapter:

JavaScript

holder_matches_sc.xml:

JavaScript

activity_schedule_sc.xml (containing activity):

JavaScript

SC_ScheduleActivity.java (containing activity)

JavaScript

Advertisement

Answer

change in this file holder_matches_sc.xml:

in

JavaScript

make it’s android:layout_height="wrap_content"

also make RecyclerView android:layout_height="match_parent"

And you also forget to put recyclerView.setAdapter(Your_adpater_name); after the recyclerView.setLayoutManager() method.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement