Search in sources :

Example 1 with BannerComponent

use of com.shizhefei.view.indicator.BannerComponent in project ViewPagerIndicator by LuckyJayce.

the class BannerActivity method onCreate.

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_banner);
    //ViewPager,Indicator
    ViewPager viewPager = (ViewPager) findViewById(R.id.banner_viewPager);
    Indicator indicator = (Indicator) findViewById(R.id.banner_indicator);
    indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.WHITE, 0, ScrollBar.Gravity.CENTENT_BACKGROUND));
    viewPager.setOffscreenPageLimit(2);
    bannerComponent = new BannerComponent(indicator, viewPager, false);
    bannerComponent.setAdapter(adapter);
    findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] {};
            adapter.notifyDataSetChanged();
        }
    });
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] { R.drawable.p2 };
            adapter.notifyDataSetChanged();
        }
    });
    findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] { R.drawable.p1, R.drawable.p2, R.drawable.p3, R.drawable.p4 };
            adapter.notifyDataSetChanged();
        }
    });
    //默认就是800毫秒,设置单页滑动效果的时间
    //        bannerComponent.setScrollDuration(800);
    //设置播放间隔时间,默认情况是3000毫秒
    bannerComponent.setAutoPlayTime(2500);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) BannerComponent(com.shizhefei.view.indicator.BannerComponent) ImageView(android.widget.ImageView) View(android.view.View) Indicator(com.shizhefei.view.indicator.Indicator) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar)

Aggregations

ViewPager (android.support.v4.view.ViewPager)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 BannerComponent (com.shizhefei.view.indicator.BannerComponent)1 Indicator (com.shizhefei.view.indicator.Indicator)1 IndicatorViewPager (com.shizhefei.view.indicator.IndicatorViewPager)1 ColorBar (com.shizhefei.view.indicator.slidebar.ColorBar)1