How to increase the the limit of items showing in recyclerView


How to increase the the limit of items showing in recyclerView



Basically I have made a RecyclerView in which I am showing all my data. At this stage code is working properly, data is showing in RecyclerView. But this is showing only nine items in the RecyclerView, not showing more. My data is greater than 9, how will I increase the limit of my data showing?


RecyclerView


RecyclerView


RecyclerView



in my fragment I have set data in recyclerView as


private void setInfo(ArrayList<CategoriesItem> arrayListCategory){

categoriesAdapter = new CategoriesAdapter(context, arrayListCategory);
rvCategories.setLayoutManager(new GridLayoutManager(context, 2,GridLayoutManager.VERTICAL,false));
rvCategories.setAdapter(categoriesAdapter);
categoriesAdapter.notifyDataSetChanged();
}



and mt adapter is


public class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolder> {

private ArrayList<CategoriesItem> categories;
private Context context;



public CategoriesAdapter(Context context, ArrayList<CategoriesItem> categories) {
this.context = context;
this.categories = categories;
}

@Override
public CategoriesAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.trending_category_home_view, parent, false);
return new CategoriesAdapter.ViewHolder(view);
}

@Override
public void onBindViewHolder(CategoriesAdapter.ViewHolder holder, int position) {
holder.setRootCategories(categories.get(position));
}

@Override
public int getItemCount() {
return categories.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{


private ImageView ivCategoryThumb;
private TextView tvCategoryTitle;


public ViewHolder(View itemView) {
super(itemView);

ivCategoryThumb = itemView.findViewById(R.id.categories);
tvCategoryTitle = itemView.findViewById(R.id.category_title);
}
public void setRootCategories(final CategoriesItem item){
tvCategoryTitle.setText(item.getCategoryName());
Picasso.get().load(item.getImageURL()).into(ivCategoryThumb);
Log.d("Category",item.getCategoryName());
}
}
}





Could you please post your RecyclerView Adapter code as an edit to your question?
– Michael Dodd
Jun 29 at 9:50





I have upload the code please check it
– Anser Abbas
Jun 29 at 9:58





If you stick some logging in, does the value of categories.size() match arrayListCategory.size()?
– Michael Dodd
Jun 29 at 10:06


categories.size()


arrayListCategory.size()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift