我有一个 viewpager,需要在其中添加一个包含图像的布局,我有 73 个图像,我正在从 pics[] 一个 int 数组列表中加载它们,所以在滑动 viewpager 以查看这些图像时,我正在获取第 7 个图像内存异常我的代码是:
public Object instantiateItem(View collection, int position) {
inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.image_view_layout, null);
ViewHolder holder = new ViewHolder();
holder.img_view = (ImageView) view.findViewById(R.id.img_pager);
//img_v=(ImageView)view.findViewById(R.id.img_pager);
int count=NUM_VIEWS-1;
view.setTag(holder);
holder.img_view.setImageResource(pics[count-position]);
((ViewPager) collection).addView(view, 0);
return view;
}