标签:pix vertica count state cti vat ges attrs err
//图片
public class PhotoViewPager extends ViewPager {
public PhotoViewPager(@NonNull Context context) {
this(context, null);
}
public PhotoViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
try {
return super.onTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
}
////////////////////////////////////////////////////
private ArrayList<View> viewList;
/**
* 初始化轮播
*/
public void initBanner(List<PhotoListResponse> responses) {
viewList = new ArrayList<View>();
for (int i = 0; responses != null && i < responses.size(); i++) {
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.air_companyculture_activity_photo_view, null);
PhotoView photoView = view.findViewById(R.id.air_photo_view_photo);
String fileId = responses.get(i).getImagesInfo().get(0).getFileId();
GlideUtil.load(this, fileId, photoView);
viewList.add(view);
}
mAdapter = new PhotoPagerAdapter(viewList);
photoPager.setAdapter(mAdapter);
photoPager.setCurrentItem(s);
photoPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
dolike(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
/////////////////////////////////////////
//上面引用布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<uk.co.senab.photoview.PhotoView
android:id="@+id/air_photo_view_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/c101" />
</LinearLayout>
////////////////////////////////
//适配器
public class PhotoPagerAdapter extends PagerAdapter {
private ArrayList<View> viewList;
public PhotoPagerAdapter(ArrayList<View> viewList) {
this.viewList = viewList;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public int getCount() {
return viewList.size();
}
@Override
public void destroyItem(ViewGroup container, int position,
Object object) {
container.removeView(viewList.get(position));
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
container.addView(viewList.get(position));
return viewList.get(position);
}
}
标签:pix vertica count state cti vat ges attrs err
原文地址:https://www.cnblogs.com/sunjian43792901/p/11962535.html