Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoopviewPager click listener not working #15

Open
arunrajgm opened this issue Nov 17, 2016 · 8 comments
Open

LoopviewPager click listener not working #15

arunrajgm opened this issue Nov 17, 2016 · 8 comments

Comments

@arunrajgm
Copy link

Hi guys,
now only i seen this library.its awesome.
But here in loop viewpager.i click on the image but its didn't trigger a click event.
i tried all ways.but no luck
Can u plz help me
Thanks.

@jeasonlzy
Copy link
Owner

you should add onClickLiatener in HeaderAdapter ,such as:

private class HeaderAdapter extends PagerAdapter {

    public int[] images = new int[]{//
                                    R.mipmap.image1, R.mipmap.image2, R.mipmap.image3,//
                                    R.mipmap.image4, R.mipmap.image5};

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        ImageView imageView = new ImageView(getApplicationContext());
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setImageResource(images[position]);
        container.addView(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), "第" + position + "页", Toast.LENGTH_SHORT).show();
            }
        });
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}

@arunrajgm
Copy link
Author

hi jeasonlzy,
I already tried this.
But its not working.
Any other way is there?

@jeasonlzy
Copy link
Owner

you can download or clone the latest code and try again, I have already added click event in demo。

@arunrajgm
Copy link
Author

Finally i got it.its works
Thank you very much for your quick response jeasonlzy..

@arunrajgm
Copy link
Author

But 1 small issue is there.
after scrolldown the loopviewpager hided.But i click on the actionbar,the loopview pager click listener is triggerd.its wrong right

@jeasonlzy
Copy link
Owner

1111

you can solve this issue by only one line of code,just make the action bar consume the click event。

@arunrajgm
Copy link
Author

Super.its solved.
In recyclerview your are using simple textview.
But in recyclerview with custom layout the loopviewpager not opening again when scroll top again .

@arunrajgm
Copy link
Author

i am facing issues on firebase recycler adater in your library..

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

No branches or pull requests

2 participants