Only one item displayed in RecyclerView [duplicate]RecyclerView adapter show only first itemRecyclerView onClickHow to add dividers and spaces between items in RecyclerView?Why doesn't RecyclerView have onItemClickListener()?How to create RecyclerView with multiple view type?RecyclerView: how to clear cached/recycled views?RecyclerView: how to catch the onClick on an ImageView?Scrolling lagged after applying the typeface in the Recycler view itemsCustom RecyclerView adapter won't allow onBindViewHolder to use pre-defined ViewHolderRecyclerView item element(imageview)clickWhy onBindViewHolder index isn't incrementing in Recycler View?

Isometric embedding of a genus g surface

Does Doodling or Improvising on the Piano Have Any Benefits?

What should be the ideal length of sentences in a blog post for ease of reading?

How would you translate "more" for use as an interface button?

I'm just a whisper. Who am I?

What does "tick" mean in this sentence?

Can I say "fingers" when referring to toes?

What (the heck) is a Super Worm Equinox Moon?

How to get directions in deep space?

Echo with obfuscation

Why is the Sun approximated as a black body at ~ 5800 K?

Why do Radio Buttons not fill the entire outer circle?

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

PTIJ: Which Dr. Seuss books should one obtain?

Do people actually use the word "kaputt" in conversation?

Pre-Employment Background Check With Consent For Future Checks

Mimic lecturing on blackboard, facing audience

Would this string work as string?

Ways of geometrical multiplication

Can I cause damage to electrical appliances by unplugging them when they are turned on?

How do I prevent inappropriate ads from appearing in my game?

Why is participating in the European Parliamentary elections used as a threat?

How do you justify more code being written by following clean code practices?

What is the meaning of the following sentence?



Only one item displayed in RecyclerView [duplicate]


RecyclerView adapter show only first itemRecyclerView onClickHow to add dividers and spaces between items in RecyclerView?Why doesn't RecyclerView have onItemClickListener()?How to create RecyclerView with multiple view type?RecyclerView: how to clear cached/recycled views?RecyclerView: how to catch the onClick on an ImageView?Scrolling lagged after applying the typeface in the Recycler view itemsCustom RecyclerView adapter won't allow onBindViewHolder to use pre-defined ViewHolderRecyclerView item element(imageview)clickWhy onBindViewHolder index isn't incrementing in Recycler View?













1
















This question already has an answer here:



  • RecyclerView adapter show only first item

    3 answers



I am debugging and I get the correct number of items from Server. And It also calls onCreateViewholder and onBindViewHolder as many as the item size.



However, my RecyclerView only show one item in the list.



And most of the problem after my search was when the height of RecyclerView is match_parent. Mine was match_parent as well. So, I changed it to wrap_content. But It gets correct the number of items and correct item data. But can't display the all the times in the Recycler view.



public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> 
ArrayList<MyData> MyDataArrayList;

public static class MyViewHolder extends RecyclerView.ViewHolder
TextView userId;

MyViewHolder(View view)
super(view);
Log.d(TAG, "created()");
tvUserID = view.findViewById(R.id.textview_myitem);



public MyAdapter (ArrayList<MyData> myDataArrayList)
Log.d(TAG, "new MyAdapter instance created");
this.myDataArrayList = myDataArrayList;


@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
Log.d(TAG, "onCreateViewHolder()");
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_item, parent, false);

return new MyViewHolder(v);


@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
Log.d(TAG, "onBindViewHolder()=nposition: " + position + ",nitem: " + myDataArrayList.get(position).toString());

MyViewHolder myViewHolder = (MyViewHolder) holder;

Log.d(TAG, "getItemCount(): " + getItemCount());
try
String username = myDataArrayList.get(position).getUser();
myViewHolder.userId.setText(username);
catch (Exception e)
e.printStackTrace();



@Override
public int getItemCount()
return myDataArrayList.size();





recyclerView = findViewById(R.id.my_recycler_view);
layoutManager = new LinearLayoutManager(MyActivity.this);
myAdapter = new myAdapter(myDataArrayList);
recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(layoutManager);


 <android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


this is my_item.xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/textview_myitem"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:text="username"
android:gravity="center_vertical"
android:paddingLeft="15dp" />
</LinearLayout>


What's the prolbem of this?










share|improve this question















marked as duplicate by Nilesh Rathod android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 4:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • have you tried to change the height to fixed size(in dp)?

    – Anton Makov
    Mar 7 at 3:28











  • @AntonMakov Yes, but didn't work.

    – c-an
    Mar 7 at 3:29











  • recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

    – Shanto George
    Mar 7 at 3:30











  • I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

    – Kingfisher Phuoc
    Mar 7 at 3:33











  • Post your my_item.xml layout code as well.

    – Viraj Patel
    Mar 7 at 3:40















1
















This question already has an answer here:



  • RecyclerView adapter show only first item

    3 answers



I am debugging and I get the correct number of items from Server. And It also calls onCreateViewholder and onBindViewHolder as many as the item size.



However, my RecyclerView only show one item in the list.



And most of the problem after my search was when the height of RecyclerView is match_parent. Mine was match_parent as well. So, I changed it to wrap_content. But It gets correct the number of items and correct item data. But can't display the all the times in the Recycler view.



public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> 
ArrayList<MyData> MyDataArrayList;

public static class MyViewHolder extends RecyclerView.ViewHolder
TextView userId;

MyViewHolder(View view)
super(view);
Log.d(TAG, "created()");
tvUserID = view.findViewById(R.id.textview_myitem);



public MyAdapter (ArrayList<MyData> myDataArrayList)
Log.d(TAG, "new MyAdapter instance created");
this.myDataArrayList = myDataArrayList;


@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
Log.d(TAG, "onCreateViewHolder()");
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_item, parent, false);

return new MyViewHolder(v);


@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
Log.d(TAG, "onBindViewHolder()=nposition: " + position + ",nitem: " + myDataArrayList.get(position).toString());

MyViewHolder myViewHolder = (MyViewHolder) holder;

Log.d(TAG, "getItemCount(): " + getItemCount());
try
String username = myDataArrayList.get(position).getUser();
myViewHolder.userId.setText(username);
catch (Exception e)
e.printStackTrace();



@Override
public int getItemCount()
return myDataArrayList.size();





recyclerView = findViewById(R.id.my_recycler_view);
layoutManager = new LinearLayoutManager(MyActivity.this);
myAdapter = new myAdapter(myDataArrayList);
recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(layoutManager);


 <android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


this is my_item.xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/textview_myitem"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:text="username"
android:gravity="center_vertical"
android:paddingLeft="15dp" />
</LinearLayout>


What's the prolbem of this?










share|improve this question















marked as duplicate by Nilesh Rathod android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 4:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • have you tried to change the height to fixed size(in dp)?

    – Anton Makov
    Mar 7 at 3:28











  • @AntonMakov Yes, but didn't work.

    – c-an
    Mar 7 at 3:29











  • recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

    – Shanto George
    Mar 7 at 3:30











  • I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

    – Kingfisher Phuoc
    Mar 7 at 3:33











  • Post your my_item.xml layout code as well.

    – Viraj Patel
    Mar 7 at 3:40













1












1








1









This question already has an answer here:



  • RecyclerView adapter show only first item

    3 answers



I am debugging and I get the correct number of items from Server. And It also calls onCreateViewholder and onBindViewHolder as many as the item size.



However, my RecyclerView only show one item in the list.



And most of the problem after my search was when the height of RecyclerView is match_parent. Mine was match_parent as well. So, I changed it to wrap_content. But It gets correct the number of items and correct item data. But can't display the all the times in the Recycler view.



public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> 
ArrayList<MyData> MyDataArrayList;

public static class MyViewHolder extends RecyclerView.ViewHolder
TextView userId;

MyViewHolder(View view)
super(view);
Log.d(TAG, "created()");
tvUserID = view.findViewById(R.id.textview_myitem);



public MyAdapter (ArrayList<MyData> myDataArrayList)
Log.d(TAG, "new MyAdapter instance created");
this.myDataArrayList = myDataArrayList;


@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
Log.d(TAG, "onCreateViewHolder()");
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_item, parent, false);

return new MyViewHolder(v);


@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
Log.d(TAG, "onBindViewHolder()=nposition: " + position + ",nitem: " + myDataArrayList.get(position).toString());

MyViewHolder myViewHolder = (MyViewHolder) holder;

Log.d(TAG, "getItemCount(): " + getItemCount());
try
String username = myDataArrayList.get(position).getUser();
myViewHolder.userId.setText(username);
catch (Exception e)
e.printStackTrace();



@Override
public int getItemCount()
return myDataArrayList.size();





recyclerView = findViewById(R.id.my_recycler_view);
layoutManager = new LinearLayoutManager(MyActivity.this);
myAdapter = new myAdapter(myDataArrayList);
recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(layoutManager);


 <android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


this is my_item.xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/textview_myitem"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:text="username"
android:gravity="center_vertical"
android:paddingLeft="15dp" />
</LinearLayout>


What's the prolbem of this?










share|improve this question

















This question already has an answer here:



  • RecyclerView adapter show only first item

    3 answers



I am debugging and I get the correct number of items from Server. And It also calls onCreateViewholder and onBindViewHolder as many as the item size.



However, my RecyclerView only show one item in the list.



And most of the problem after my search was when the height of RecyclerView is match_parent. Mine was match_parent as well. So, I changed it to wrap_content. But It gets correct the number of items and correct item data. But can't display the all the times in the Recycler view.



public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> 
ArrayList<MyData> MyDataArrayList;

public static class MyViewHolder extends RecyclerView.ViewHolder
TextView userId;

MyViewHolder(View view)
super(view);
Log.d(TAG, "created()");
tvUserID = view.findViewById(R.id.textview_myitem);



public MyAdapter (ArrayList<MyData> myDataArrayList)
Log.d(TAG, "new MyAdapter instance created");
this.myDataArrayList = myDataArrayList;


@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
Log.d(TAG, "onCreateViewHolder()");
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_item, parent, false);

return new MyViewHolder(v);


@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
Log.d(TAG, "onBindViewHolder()=nposition: " + position + ",nitem: " + myDataArrayList.get(position).toString());

MyViewHolder myViewHolder = (MyViewHolder) holder;

Log.d(TAG, "getItemCount(): " + getItemCount());
try
String username = myDataArrayList.get(position).getUser();
myViewHolder.userId.setText(username);
catch (Exception e)
e.printStackTrace();



@Override
public int getItemCount()
return myDataArrayList.size();





recyclerView = findViewById(R.id.my_recycler_view);
layoutManager = new LinearLayoutManager(MyActivity.this);
myAdapter = new myAdapter(myDataArrayList);
recyclerView.setAdapter(myAdapter);
recyclerView.setLayoutManager(layoutManager);


 <android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


this is my_item.xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/textview_myitem"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="25dp"
android:text="username"
android:gravity="center_vertical"
android:paddingLeft="15dp" />
</LinearLayout>


What's the prolbem of this?





This question already has an answer here:



  • RecyclerView adapter show only first item

    3 answers







android android-recyclerview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 3:42







c-an

















asked Mar 7 at 3:14









c-anc-an

567426




567426




marked as duplicate by Nilesh Rathod android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 4:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Nilesh Rathod android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 7 at 4:06


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • have you tried to change the height to fixed size(in dp)?

    – Anton Makov
    Mar 7 at 3:28











  • @AntonMakov Yes, but didn't work.

    – c-an
    Mar 7 at 3:29











  • recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

    – Shanto George
    Mar 7 at 3:30











  • I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

    – Kingfisher Phuoc
    Mar 7 at 3:33











  • Post your my_item.xml layout code as well.

    – Viraj Patel
    Mar 7 at 3:40

















  • have you tried to change the height to fixed size(in dp)?

    – Anton Makov
    Mar 7 at 3:28











  • @AntonMakov Yes, but didn't work.

    – c-an
    Mar 7 at 3:29











  • recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

    – Shanto George
    Mar 7 at 3:30











  • I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

    – Kingfisher Phuoc
    Mar 7 at 3:33











  • Post your my_item.xml layout code as well.

    – Viraj Patel
    Mar 7 at 3:40
















have you tried to change the height to fixed size(in dp)?

– Anton Makov
Mar 7 at 3:28





have you tried to change the height to fixed size(in dp)?

– Anton Makov
Mar 7 at 3:28













@AntonMakov Yes, but didn't work.

– c-an
Mar 7 at 3:29





@AntonMakov Yes, but didn't work.

– c-an
Mar 7 at 3:29













recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

– Shanto George
Mar 7 at 3:30





recyclerView.setLayoutManager(layoutManager); Please use this before setAdapter

– Shanto George
Mar 7 at 3:30













I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

– Kingfisher Phuoc
Mar 7 at 3:33





I assume that you're forgetting to call notifyDataChanged() after adding more items into your myAdapter.

– Kingfisher Phuoc
Mar 7 at 3:33













Post your my_item.xml layout code as well.

– Viraj Patel
Mar 7 at 3:40





Post your my_item.xml layout code as well.

– Viraj Patel
Mar 7 at 3:40












2 Answers
2






active

oldest

votes


















2














My_item.xml has width and height of matchparent ,change the height to wrap content.






share|improve this answer























  • And change recyclerview height as match parent.

    – raj kavadia
    Mar 7 at 3:48






  • 1





    I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

    – c-an
    Mar 7 at 3:49











  • If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

    – raj kavadia
    Mar 7 at 5:28


















1














The problem is in your my_item.xml file.
You have to set android:layout_height="wrap_content" instead of android:layout_height="match_parent"and it will work and display all items.



In existing code, it is also adding all items but due to match_parent you are able to see only one item. If you scroll the RecyclerView then you will be able to see other items as well.



Also, you can keep RecyclerView height as match_parent as per your need.






share|improve this answer





























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    My_item.xml has width and height of matchparent ,change the height to wrap content.






    share|improve this answer























    • And change recyclerview height as match parent.

      – raj kavadia
      Mar 7 at 3:48






    • 1





      I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

      – c-an
      Mar 7 at 3:49











    • If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

      – raj kavadia
      Mar 7 at 5:28















    2














    My_item.xml has width and height of matchparent ,change the height to wrap content.






    share|improve this answer























    • And change recyclerview height as match parent.

      – raj kavadia
      Mar 7 at 3:48






    • 1





      I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

      – c-an
      Mar 7 at 3:49











    • If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

      – raj kavadia
      Mar 7 at 5:28













    2












    2








    2







    My_item.xml has width and height of matchparent ,change the height to wrap content.






    share|improve this answer













    My_item.xml has width and height of matchparent ,change the height to wrap content.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 7 at 3:47









    raj kavadiaraj kavadia

    1538




    1538












    • And change recyclerview height as match parent.

      – raj kavadia
      Mar 7 at 3:48






    • 1





      I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

      – c-an
      Mar 7 at 3:49











    • If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

      – raj kavadia
      Mar 7 at 5:28

















    • And change recyclerview height as match parent.

      – raj kavadia
      Mar 7 at 3:48






    • 1





      I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

      – c-an
      Mar 7 at 3:49











    • If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

      – raj kavadia
      Mar 7 at 5:28
















    And change recyclerview height as match parent.

    – raj kavadia
    Mar 7 at 3:48





    And change recyclerview height as match parent.

    – raj kavadia
    Mar 7 at 3:48




    1




    1





    I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

    – c-an
    Mar 7 at 3:49





    I was so stupid... thanks. And I think for the Recyclerview the height must be wrap_content as far as I know.

    – c-an
    Mar 7 at 3:49













    If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

    – raj kavadia
    Mar 7 at 5:28





    If the root layout is the linear layout than use property of weight otherwise use match parent of fixed size to make sure that the minimum 2 to 3 rows are displayed.

    – raj kavadia
    Mar 7 at 5:28













    1














    The problem is in your my_item.xml file.
    You have to set android:layout_height="wrap_content" instead of android:layout_height="match_parent"and it will work and display all items.



    In existing code, it is also adding all items but due to match_parent you are able to see only one item. If you scroll the RecyclerView then you will be able to see other items as well.



    Also, you can keep RecyclerView height as match_parent as per your need.






    share|improve this answer



























      1














      The problem is in your my_item.xml file.
      You have to set android:layout_height="wrap_content" instead of android:layout_height="match_parent"and it will work and display all items.



      In existing code, it is also adding all items but due to match_parent you are able to see only one item. If you scroll the RecyclerView then you will be able to see other items as well.



      Also, you can keep RecyclerView height as match_parent as per your need.






      share|improve this answer

























        1












        1








        1







        The problem is in your my_item.xml file.
        You have to set android:layout_height="wrap_content" instead of android:layout_height="match_parent"and it will work and display all items.



        In existing code, it is also adding all items but due to match_parent you are able to see only one item. If you scroll the RecyclerView then you will be able to see other items as well.



        Also, you can keep RecyclerView height as match_parent as per your need.






        share|improve this answer













        The problem is in your my_item.xml file.
        You have to set android:layout_height="wrap_content" instead of android:layout_height="match_parent"and it will work and display all items.



        In existing code, it is also adding all items but due to match_parent you are able to see only one item. If you scroll the RecyclerView then you will be able to see other items as well.



        Also, you can keep RecyclerView height as match_parent as per your need.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 3:48









        Viraj PatelViraj Patel

        991315




        991315













            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved