Closed sami-khleaf closed 5 years ago
How are you updating the items in the adapter? Also, does your Adapter's getItemCount()
method return the actual number of items?
@Arasthel i am just showing the items for now
no actions or customizations applied on any item
also the getItemCount()
always returns 4
i don't know where the issue is
This is the current library sample with only 4 items:
So there must be some issue with either the layout of your items or how you update them. Without that code, there's not much I can do.
@Arasthel the samples works fine but im using the library in a custom Widget i've created i only add the widget in the XML. the recycler code and the layout managers code is in the custom widget
I've tried different ways to break the LayoutManager by setting match_parent
, fixed sizes or huge children views on the items, even using complex ViewGroups such as ConstraintLayout as the root view of the items and it still worked. I can't help you if I don't know what you've done by looking at some actual code.
also mine :\
also mine :\
Could you provide some code so I can reproduce it and debug it? Thanks.
Here is the code in activity
spannedGridLayoutManager = new SpannedGridLayoutManager(
SpannedGridLayoutManager.Orientation.VERTICAL, 4);
spannedGridLayoutManager.setItemOrderIsStable(true);
recyclerview.setLayoutManager(spannedGridLayoutManager);
recyclerview.setAdapter(categoryAdapter);
and here in adapter
if (type == Const.GRID) {
Timber.d("type grid");
if (position % 3 == 0) {
width = 2;
height = 2;
} else if (position % 3 != 0) {
width = 2;
height = 1;
}
holder.itemView.setLayoutParams(new SpanLayoutParams(new SpanSize(width, height)));
}
am using two type of layout grid and linear and the items shown in linear way but the SpannedGridLayoutManager didn't show any thing.
What are all the assigned width and height values? I just tried with your code and got this:
should i give height and width for items ? first i made it match_parent for height and width , and after i gave it specific width and height it still doesn't appear. i am using custom adapter and the items are images with some text.
I meant for the SpanSize. On the snippet you posted, you set the SpanSizes if the type is GRID, but what about the rest of types? Do they also have defined SpanSizes?
If this was related to a scrolling issue because the adapter was empty when first presented, this should be fixed on version 3.0.1.
In the Adapter onCreate/onBindViewHolder are not called!!