public Object instantiateItem(ViewGroup container, int position) {
// Declare Variables
TextView txtrank;
ImageView imgflag;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.viewpager_item, container,
false);
// Locate the TextViews in viewpager_item.xml
txtrank = (TextView) itemView.findViewById(R.id.rank);
// Capture position and set to the TextViews
txtrank.setText(worldpopulationlist.get(position).getImage());
// Locate the ImageView in viewpager_item.xml
imgflag = (ImageView) itemView.findViewById(R.id.flag);
// Capture position and set to the ImageView
// imgflag.setImageResource(flag[position]);
String smage= worldpopulationlist.get(position).getImage();
Uri uri = Uri.parse(worldpopulationlist.get(position).getImage());
Picasso.with(context)
.load(uri)
.into(imgflag);
// Add viewpager_item.xml to ViewPager
((ViewPager) container).addView(itemView);
return itemView;
}
此处图片来自parse.com服务器,第一次加载,然后移动到该位置后重新加载。