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