com.youth.banner.listener.OnBannerListener Java Examples
The following examples show how to use
com.youth.banner.listener.OnBannerListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BannerFragment.java From AndroidQuick with MIT License | 6 votes |
@Override protected void initViewsAndEvents(Bundle savedInstanceState) { List<String> imageUrls = new ArrayList<>(); imageUrls.add("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3356121154,1179528716&fm=27&gp=0.jpg"); imageUrls.add("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2533643392,3611141887&fm=27&gp=0.jpg"); imageUrls.add("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=403151593,358130787&fm=27&gp=0.jpg"); List<String> titles = new ArrayList<>(); titles.add("图片一"); titles.add("图片二"); titles.add("图片三"); mBanner.setOnBannerListener(new OnBannerListener() { @Override public void OnBannerClick(int position) { ToastUtil.showToast(position); } }); mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE) .setIndicatorGravity(BannerConfig.RIGHT) .setImageLoader(new GlideImageLoader()) .setImages(imageUrls) .setBannerTitles(titles) .setDelayTime(3000) .start(); }
Example #2
Source File: DataBindingAdapter.java From RvHelper with Apache License 2.0 | 6 votes |
@BindingAdapter(value = {"data", "bannerListener"}, requireAll = false) public static void setSlider(Banner banner, String data, OnBannerListener onBannerListener) { List<String> banners = new ArrayList<>(); banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner01.jpg"); banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner02.jpg"); banners.add("https://res.darryring.com/activity/drSEM_storeLandingPage/temp/part04_banner03.jpg"); banners.add("https://static.darryring.com/ueditor/2017-03-28/1490687105.jpg"); banner.setAdapter(new ImageAdapter(banners)); banner.setIndicator(new CircleIndicator(banner.getContext())); banner.setIndicatorSelectedColorRes(R.color.colorAccent); banner.setIndicatorNormalColorRes(android.R.color.white); banner.setIndicatorGravity(IndicatorConfig.Direction.LEFT); banner.setIndicatorSpace((int) BannerUtils.dp2px(20)); banner.setIndicatorMargins(new IndicatorConfig.Margins((int) BannerUtils.dp2px(10))); banner.setIndicatorWidth(10, 20); //banner.addItemDecoration(new MarginItemDecoration((int) BannerUtils.dp2px(50))); //banner.setPageTransformer(new DepthPageTransformer()); banner.setOnBannerListener(onBannerListener); //banner.addOnPageChangeListener(onBannerListener); banner.start(); }
Example #3
Source File: HomeAdapter.java From playa with MIT License | 5 votes |
@Override public void bind() { bannerView.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE); bannerView.setImageLoader(new ImageLoader() { @Override public void displayImage(Context context, Object path, ImageView imageView) { Glide.with(context).load(path).into(imageView); } }); List<String> bannerImageList = new ArrayList<>(); final List<String> bannerTitleList = new ArrayList<>(); final List<String> bannerUrlList = new ArrayList<>(); for (Banner banner : bannerData) { bannerImageList.add(banner.getImagePath()); bannerTitleList.add(banner.getTitle()); bannerUrlList.add(banner.getUrl()); } bannerView.setImages(bannerImageList); bannerView.setBannerTitles(bannerTitleList); bannerView.isAutoPlay(true); bannerView.setIndicatorGravity(BannerConfig.RIGHT); bannerView.setDelayTime(5000); bannerView.setOnBannerListener(new OnBannerListener() { @Override public void OnBannerClick(int position) { Intent intent = new Intent(itemView.getContext(), BrowserActivity.class); intent.putExtra("URL", bannerUrlList.get(position)); intent.putExtra("TITLE", bannerTitleList.get(position)); itemView.getContext().startActivity(intent); } }); bannerView.start(); }
Example #4
Source File: ImmersionActivity.java From AndroidQuick with MIT License | 5 votes |
@Override protected void initViewsAndEvents(Bundle savedInstanceState) { List<String> imageUrls = new ArrayList<>(); imageUrls.add("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3356121154,1179528716&fm=27&gp=0.jpg"); imageUrls.add("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2533643392,3611141887&fm=27&gp=0.jpg"); imageUrls.add("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=403151593,358130787&fm=27&gp=0.jpg"); List<String> titles = new ArrayList<>(); titles.add("图片一"); titles.add("图片二"); titles.add("图片三"); mBanner.setOnBannerListener(new OnBannerListener() { @Override public void OnBannerClick(int position) { switch (position) { case 0://黑色字体 StatusBarUtil.setTranslucentStatus(ImmersionActivity.this);//透明状态栏 StatusBarUtil.setStatusBarDarkTheme(ImmersionActivity.this, true); break; case 1://白色字体 StatusBarUtil.setStatusBarDarkTheme(ImmersionActivity.this, false); break; case 2: //设置白色字体,其他背景 StatusBarUtil.setStatusBarDarkTheme(ImmersionActivity.this, false); StatusBarUtil.setStatusBarColor(ImmersionActivity.this, Color.parseColor("#58C087"));//设置背景颜色 break; } } }); mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE) .setIndicatorGravity(BannerConfig.RIGHT) .setImageLoader(new GlideImageLoader()) .setImages(imageUrls) .setBannerTitles(titles) .setDelayTime(3000) .start(); }
Example #5
Source File: WelcomeActivity.java From HomeApplianceMall with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Window win = getWindow();//返回当前Activity的Window对象,Window类中概括了Android窗口的基本属性和基本功能 //隐藏状态栏 win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏 setContentView(R.layout.activity_welcome); images = new ArrayList<>(); images.add(R.drawable.welcome_1); images.add(R.drawable.welcome_2); images.add(R.drawable.welcome_3); images.add(R.drawable.welcome_4); images.add(R.drawable.welcome_5); final Banner banner = (Banner) findViewById(R.id.welcomBanner); //设置banner样式 banner.setBannerStyle(BannerConfig.NUM_INDICATOR); //设置图片加载器 banner.setImageLoader(new GlideImageLoader()); //设置图片集合 banner.setImages(images); //设置banner动画效果 banner.setBannerAnimation(Transformer.Default); //设置自动轮播,默认为true banner.isAutoPlay(false); //设置指示器位置(当banner模式中有指示器时) banner.setIndicatorGravity(BannerConfig.RIGHT); //banner设置方法全部调用完毕时最后调用 banner.start(); banner.setOnBannerListener(new OnBannerListener() { @Override public void OnBannerClick(int position) { if(images.size()-1 == position){ Intent intent = new Intent(WelcomeActivity.this,MainActivity.class); startActivity(intent); finish(); } } }); }
Example #6
Source File: Banner.java From HomeApplianceMall with MIT License | 2 votes |
/** * 废弃了旧版接口,新版的接口下标是从1开始,同时解决下标越界问题 * * @param listener * @return */ public Banner setOnBannerListener(OnBannerListener listener) { this.listener = listener; return this; }
Example #7
Source File: Banner.java From WanAndroid with GNU General Public License v3.0 | 2 votes |
/** * 废弃了旧版接口,新版的接口下标是从1开始,同时解决下标越界问题 * * @param listener * @return */ public Banner setOnBannerListener(OnBannerListener listener) { this.listener = listener; return this; }