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

Carousel notifyOnSetChanged() not working #11

Open
sarahachem opened this issue Mar 6, 2016 · 0 comments
Open

Carousel notifyOnSetChanged() not working #11

sarahachem opened this issue Mar 6, 2016 · 0 comments

Comments

@sarahachem
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant