Skip to content

chenyuAndroid/BannerViewPager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BannerViewPager

ViewPager with indicator and auto-rolling function. 带指示器的、支持自动轮播的ViewPager

pic01 pic02

How to use it?

1、add the BannerViewPager to your xml files:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.chenyu.library.bannerViewPager.BannerViewPager
        android:id="@+id/banner"
        android:layout_width="match_parent"
        android:layout_height="200dp">

    </com.chenyu.library.bannerViewPager.BannerViewPager>

    <!-- others -->
</LinearLayout>

2、get the instance of BannerViewPager,and the set adapter for it.

//获取BannerViewPager实例
bannerViewPager = (BannerViewPager) findViewById(R.id.banner);
//实例化ViewPagerAdapter,第一个参数是View集合,第二个参数是页面点击监听器
mAdapter = new ViewPagerAdapter(mViews, new OnPageClickListener() {
    @Override
    public void onPageClick(View view, int position) {
        Log.d("cylog","position:"+position);
    }
});
//设置适配器
bannerViewPager.setAdapter(mAdapter);

Update

2017-04-04

1、Fix some bugs which may lead to the a memory leak.For example,it will remove the runnable from view each time the BannerViewPager becomes INVISIBLE or GONE.It means that BannerViewPager will stop auto-rolling while it is INVISIBLE or GONE.

About

带指示器的、支持自动轮播的ViewPager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages