CarouselPicker
CarouselPicker copied to clipboard
setItemClickListener
How to setItemClickListener?I set OnClickListener to the ItemView.The current selected one can receive events but the others can not receive events.
code like this
public Object instantiateItem(@NonNull ViewGroup container, final int position) {
View view = LayoutInflater.from(SwitchWheelActivity.this).inflate(
R.layout.item_text, container, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
TextView textView = view.findViewById(R.id.tv_type);
textView.setText(titles[position]);
container.addView(view);
return view;
}
You can extract the local views from the adapter and assign onClickListeners to each. I needed to set click events on each views to transition the pager to the relevant view, so I did this:
View[] localViews = adapter.getLocalViews(); for(int k=0; k<localViews.length; k++) { int finalK = k; localViews[k].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { carousel_image_video_selector.setCurrentItem(finalK); } }); }
ok, so I have a whole buch of images in a carousel, but how do I add click functionality to them. I've been asking about it here (you can see my code here too):
And when the specific item is in the middle, the function is called. I don't want this. I want it to call when I click on the image, not when it is in the middle of the carousel. and ideas?