- Notifications
You must be signed in to change notification settings - Fork47
InfiniteViewPager is a modified android ViewPager widget that allows infinite paging and auto-scrolling.
License
NotificationsYou must be signed in to change notification settings
waylife/InfiniteViewPager
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
https://github.com/waylife/InfiniteViewPager
- Automatically scroll to next page
- Smoothly scrolls from the end page to the first page,so does first to end.
- View reuse support, no worrying about OOM
- With indicator support(Modification ofViewpagerIncicator)
- Fluid when invoking ViewPager.setCurrentItem(), better thanthe common solution
Almost the same as the viewpager. Below are some steps.
<RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="200dp"> <com.zanlabs.widget.infiniteviewpager.InfiniteViewPagerandroid:id="@+id/viewpager"android:layout_width="match_parent"android:layout_height="fill_parent"android:visibility="visible" /> <com.zanlabs.widget.infiniteviewpager.indicator.LinePageIndicatorandroid:id="@+id/indicator"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"app:fillColor="#e3ffc7"app:pageColor="#5fff65" /> </RelativeLayout>
Similar as the implement of BaseAdapter.You need to overide the getView and getItemCount(not getCount) mehtod.
@OverridepublicViewgetView(intposition,Viewview,ViewGroupcontainer) {ViewHolderholder;if (view !=null) {holder = (ViewHolder)view.getTag(); }else {view =mInflater.inflate(R.layout.item_infinite_viewpager,container,false);holder =newViewHolder(view);view.setTag(holder); }PagerItemitem =mList.get(position);holder.position =position;holder.name.setText(item.getName());holder.description.setText(item.getDesc()+"position:"+position);Picasso.with(mContext).load(item.getImageUrl()).placeholder(R.mipmap.bg_loding_horizontal).into(holder.image);returnview; }@OverridepublicintgetItemCount() {returnmList==null?0:mList.size(); }
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {//MockPagerAdapterpagerAdapter =newMockPagerAdapter(this);pagerAdapter.setDataList(MockDataGenerator.getViewPagerData());mViewPager.setAdapter(pagerAdapter);mViewPager.setAutoScrollTime(5000);mViewPager.startAutoScroll();mLineIndicator.setViewPager(mViewPager);// }@OverridepublicvoidonStart() {super.onStart();if (mViewPager !=null)mViewPager.startAutoScroll(); }@OverridepublicvoidonStop() {if (mViewPager !=null)mViewPager.stopAutoScroll();super.onStop(); }
More You can refer to the sample project.
The MIT License.
About
InfiniteViewPager is a modified android ViewPager widget that allows infinite paging and auto-scrolling.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
