Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Repository files navigation

https://github.com/waylife/InfiniteViewPager

中文English

Function

  • 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

Preview

Sample demo

Usage

Almost the same as the viewpager. Below are some steps.

define in xml layout

        <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>

implement the InfinitePagerAdapter

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();     }

setup in activity or fragment.

@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.

Thanks to

License

The MIT License.

About

InfiniteViewPager is a modified android ViewPager widget that allows infinite paging and auto-scrolling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp