This repository was archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Carousel notifyOnSetChanged() not working #11
Copy link
Copy link
Open
Description
Hi I am using your library and it works very well until I try to update one of the carousel items programmatically.
I do the following when I create my Activity:
listVideoLeft = (Carousel) findViewById(R.id.carousel1);
photos = getPhotos(); //get all available photos
updateList(index); // display only first 5 photos in the carousel (which are added to a tempPhotos list
adapter = new MyAdapter(this, tempPhotos);
listVideoLeft.setAdapter(adapter);
adapter.notifyDataSetChanged();
On click volume button down, I want to remove the first photo in tempPhotos and add a new one
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
if (action == KeyEvent.ACTION_DOWN) {
if (photos.size() > 0) {
tempPhotos.remove(0);
tempPhotos.add(photos.get(newIndex));
adapter.notifyDataSetChanged();
listVideoLeft.invalidate();
}
}
}
However, nothing changes in my carousel. Any ideas on the reason why it doesn't work in this case? as far as I know, in Adapter the notifyDataSetChanged in all you need to let the adapter know it's data has changed and it should update
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels