I am getting three images from response,and i am storing in arraylist,then i try to set in PagerAdapter,but nothing display in my view pager,following is my pageradapter class,can any one tell that what is mistake i made?
I am using Fragment
In my Postexecute i am setting it in view pager like this
adapter = new ImageAdapter(All_Product_Details.this.getActivity());
viewPager.setAdapter(adapter);
}
below is my adapter which i set after asynctask
public class ImageAdapter extends FragmentPagerAdapter {
Context context;
ImageAdapter(Context context)
{
this.context=context;
}
@Override
public int getCount() {
return multimglist.size();
}
@Override
public Fragment getItem(int i) {
return null;
}
@Override
public void destroyItem(View container, int position, Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(
R.dimen.activity_horizontal_margin);
imageView.setPadding(padding, padding, padding, padding);
//imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
Picasso.with(context).load(multimglist.get(position)).into(imageView);
// imageView.setImageURI(Uri.parse(imgStr[position]));
((ViewPager) container).addView(imageView, 0);
return imageView;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…