sayyam / carouselview

A simple library to add carousel view in android app.
Apache License 2.0
1.15k stars 260 forks source link

How to change the sampleImages data? #89

Open rakeshg147 opened 6 years ago

rakeshg147 commented 6 years ago

I have set three images in sampleImages array. On click of a button, i want to change the images. When i set new data to sampleImages, the listener does not get called. When is the listener invoked? How do I change the data? Any help is appreciated.

E-Mwaurer commented 4 years ago

@rakeshg147 This is what I did and it works like charm. I had to reset the pageCount to the size of the new array like

btnChange.setOnClickListener {

// reset your array to hold a set of new images
            sampleImages = intArrayOf(
                R.drawable.ic_image_2,
                R.drawable.ic_image_3,
                R.drawable.ic_image_4
            )

// don't forget to set the carousel page count to the size of new array of images
            customCarouselView.pageCount = sampleImages.size
        }

which worked like charm.