0
public Object instantiateItem(View collection, int position) {
View v = collection;
if (v == null) {
LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.gallery_layout, null);
}
final String url = listOfImages.get(position);
TextView tv = (TextView)v.findViewById(R.id.textView1);
tv.setText(url);
tv.setTextColor(Color.WHITE);
tv.setTextSize(30);
((ViewPager) v).addView(tv,0);
return v;
}
上面可能是ViewPager的一个非常糟糕的实现。我试图只为每个页面使用我的XML布局。我基于我的代码使用我的图库小部件,但我不认为它会一样。将ViewPager适配器中的内容添加到xml布局中