我有一个带有数组的 viewPage 有 3 张图片,我想在缩放其中一个时锁定 viewPager,因为当我在右侧滚动时会出现下一张照片!这是我的代码
enter code here
public class ExploreImageAdapter extends PagerAdapter {
Context context;
boolean touchEvent;
private int[] exploreImages = new int[] {
R.drawable.carfourele,
R.drawable.carfourele2,
R.drawable.carfourele3,
R.drawable.carfourele4
};
private LayoutInflater inflater;
ExploreImageAdapter(Context context){
this.context=context;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (int i=1 ; i<=exploreImages.length ; i++){
} }
@Override
public int getCount() {
return exploreImages.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((View) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View topImageLayout = inflater.inflate(R.layout.item_pager_images, container, false);
int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
TouchImageView imageView= (TouchImageView)topImageLayout.findViewById(R.id.image);
imageView.setFocusable(true);
imageView.setPadding(padding, padding, padding, padding);
imageView.setImageResource(exploreImages[position]);
imageView.setMaxZoom(4f);
((ViewPager) container).addView(topImageLayout, 0);
return topImageLayout;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView((View) object);
}
}