Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Trinea/android-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinea committed May 29, 2014
2 parents 655cd22 + d4588eb commit 2770ba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cn/trinea/android/demo/AutoScrollViewPagerDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void onCreate(Bundle savedInstanceState) {

viewPager.setInterval(2000);
viewPager.startAutoScroll();
viewPager.setCurrentItem(Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % imageIdList.size());

// the more properties whose you can set
// // set whether stop auto scroll when touching, default is true
Expand Down
7 changes: 5 additions & 2 deletions src/cn/trinea/android/demo/adapter/ImagePagerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ public class ImagePagerAdapter extends PagerAdapter {
private Context context;
private List<Integer> imageIdList;

private int size;

public ImagePagerAdapter(Context context, List<Integer> imageIdList) {
this.context = context;
this.imageIdList = imageIdList;
this.size = ListUtils.getSize(imageIdList);
}

@Override
public int getCount() {
return ListUtils.getSize(imageIdList);
return Integer.MAX_VALUE;// ListUtils.getSize(imageIdList);
}

@Override
Expand All @@ -43,7 +46,7 @@ public boolean isViewFromObject(View view, Object object) {
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(imageIdList.get(position));
imageView.setImageResource(imageIdList.get(position % size));
((ViewPager)container).addView(imageView, 0);
return imageView;
}
Expand Down

0 comments on commit 2770ba8

Please sign in to comment.