Set the custom views dynamically
amineMpdam opened this issue · 4 comments
i was wondering if was it possible to fetch the objects from a data source (server for instance) and use them to populate the carouselview ??
Implement the ViewListener (as stated in the README) and there you can dynamically customise each page of the carousel.
Which i did but see i am using retrofit to fetch the data asynchronously from the server, so when the carousel is instanciated the data is not ready yet so i end up with an empty carousel.
Right. The way I do it is that on response I just grab the correct view from the ViewPager using checking in a for loop:
View carouselPage = ((View) ((CarouselViewPager) ((CarouselView) customCarouselView).getChildAt(0)).getChildAt(i));
and then set all the views inside that way calling findViewById
on carouselPage
. There's probably a more optimised way to do that.
Ahh i see, i'll give it a try and give you a feed back 👍 thank you very much for the help