Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Carousel notifyOnSetChanged() not working #11

@sarahachem

Description

@sarahachem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions