CarouselPicker icon indicating copy to clipboard operation
CarouselPicker copied to clipboard

setItemClickListener

Open TokenYc opened this issue 6 years ago • 2 comments

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;
        }

TokenYc avatar Jul 19 '18 07:07 TokenYc

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); } }); }

davidhowe avatar Dec 28 '18 15:12 davidhowe

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):

Stackoverflow

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?

CWrecker avatar Feb 10 '19 15:02 CWrecker