HeaderViewPager
HeaderViewPager copied to clipboard
LoopviewPager click listener not working
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.
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;
}
}
hi jeasonlzy, I already tried this. But its not working. Any other way is there?
you can download or clone the latest code and try again, I have already added click event in demo。
Finally i got it.its works Thank you very much for your quick response jeasonlzy..
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
you can solve this issue by only one line of code,just make the action bar consume the click event。
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 .
i am facing issues on firebase recycler adater in your library..