Comments (8)
@FabianTerhorst that's how the RecyclerView adapter works.
How have you removed the item?
In general you should call
itemAdapter.remove(int position);
This will not only remove the item at the given position, but it will also notify the adapter about the removed item so it can animate
from fastadapter.
@mikepenz when im calling mItemAdapter.notifyDataSetChanged(); it doesn´t crashes too, but when the data comes from a api for example and you get 3 items and before you got 4 items, you couldn´t know that.
from fastadapter.
@FabianTerhorst then you should provide this via a new List
and not by modifiying the previously set list
As mentioned this is the way how adapters work with the RecyclerView
that's no behavior changed by this lib
from fastadapter.
@mikepenz thanks, creating a new ArrayList works.
from fastadapter.
@FabianTerhorst to get a bit more into detail:
Yes it may work if we call notifyDataSetChanged()
, but that's not true. If you set a list to the ItemAdapter
you change all items of this adapter, but this one may isn't the only adapter providing items, and there are other adapters which also host items inside the RecyclerView
as this is the case, we want to animate the change of items, so i call
notifyAdapterItemRangeChanged
and make sure the Adapter know how to correclty animate the changed items.
So in case when set
is used, it is important that we really set a new list. If we set the previous used list it will cause problems inside the Adapter
. If you modify items of the current list, the specific methods for those actions should be used
from fastadapter.
Please refer the stackoverflow post
from fastadapter.
@drayan85 that solution is only changes name of the exception. After catching IOOB exception, another exception Added View has RecyclerView as parent but view is not a real child. Unfiltered index:n
starts to throw. I managed to fix it by wrapping set/add methods with Handler.postDelayed
. But I still get Scrapped or attached views may not be recycled. isScrap:false isAttached:true
, if I scroll down fast.
from fastadapter.
I had similiar issue, and also this solution has helped me, after I've added new item to my RV:
recyclerView.getRecycledViewPool().clear();
adapter.notifyDataSetChanged();
from fastadapter.
Related Issues (20)
- how to use multiple items for different models with Model Adapter HOT 3
- compile error HOT 2
- CreateBinding is being called each time item is being collapsed or expanded. HOT 8
- Setting a Snackbar using UndoHelper's withSnackbar does nothing.
- List is not updating after adapter.set()
- Second added item is blank HOT 6
- SelectExtensions.select() not working when create view HOT 2
- Is there any way to add multiple row? HOT 5
- How made dynamic model list? HOT 6
- Overload resolution ambiguity. All these functions match. HOT 4
- How can I judge the item is the last one in AbstractBindingItem HOT 1
- EventHook + RecycledViewPool HOT 3
- How to get access to function of Item from ViewHolder? HOT 4
- ItemFilter publishResults NPE HOT 1
- FastAdapter intercepting clicks for other ViewPager tabs HOT 1
- Drag & drop - animation is broken HOT 1
- could not resolve FastItemAdapter , FooterAdapter, ProgressItem HOT 3
- Weird behavior on scroll with expandable HOT 2
- Runtime layout changes can affect more than one item HOT 5
- Can I Swipe item view then remain it's state then delete button can click HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastadapter.