com.youth.banner.BannerConfig Java Examples

The following examples show how to use com.youth.banner.BannerConfig. 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: RvSimpleAdapter.java    From likeJDGoodsDetails with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
	if (holder instanceof BannerViewHolder){
		images=new ArrayList<>();
		images.add("http://d.hiphotos.baidu.com/image/pic/item/e7cd7b899e510fb38c2414d0d433c895d1430cb3.jpg");
		images.add("http://b.hiphotos.baidu.com/image/pic/item/11385343fbf2b2119202e609c78065380cd78e4c.jpg");
		images.add("http://h.hiphotos.baidu.com/image/pic/item/dcc451da81cb39dbc1f90411dd160924ab1830bf.jpg");
		((BannerViewHolder) holder).mBanner.setImages(images).setImageLoader(new GlideImageLoader()).isAutoPlay(false).setBannerStyle(BannerConfig.NUM_INDICATOR).start();
	}
	if (holder instanceof MyViewHolder){
		if (position==mList.size()-1){
			((MyViewHolder) holder).tv.setText("上滑查看图文详情");
			((MyViewHolder) holder).tv.setBackgroundColor(Color.parseColor("#4D88FF"));
		}else {
			((MyViewHolder) holder).tv.setText("simple "+position);
			((MyViewHolder) holder).tv.setBackgroundColor(Color.parseColor("#eeeeee"));
		}

	}
}
 
Example #2
Source File: BannerFragment.java    From AndroidQuick with MIT License 6 votes vote down vote up
@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 #3
Source File: MainFragment.java    From NoVIP with Apache License 2.0 6 votes vote down vote up
private void show_ad(List<Ad> ads){
    List<String> images = new ArrayList<>();
    List<String> titles = new ArrayList<>();
    for(int i=0;i<ads.size();i++){
        images.add(ads.get(i).getPicture_url());
        titles.add(ads.get(i).getName());
    }
    //设置banner样式
    banner.setBannerStyle(BannerConfig.NUM_INDICATOR_TITLE);
    //设置图片加载器
    banner.setImageLoader(new BannerADImageLoader());
    //设置banner动画效果
    banner.setBannerAnimation(Transformer.DepthPage);
    //设置自动轮播,默认为true
    banner.isAutoPlay(true);
    //设置轮播时间
    banner.setDelayTime(1500);
    //设置指示器位置(当banner模式中有指示器时)
    banner.setIndicatorGravity(BannerConfig.CENTER);
    //设置图片集合
    banner.setImages(images);
    //设置标题集合(当banner样式有显示title时)
    banner.setBannerTitles(titles);
    //banner设置方法全部调用完毕时最后调用
    banner.start();
}
 
Example #4
Source File: HomePage.java    From MarketAndroidApp with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化绑定控件
 *
 * @param view view
 */
public void initView(View view) {

    mRefreshLayout = view.findViewById(R.id.refresh_layout);
    viewPager = view.findViewById(R.id.viewPager);
    //初始化小圆点指示器
    points = view.findViewById(R.id.points);

    //绑定两个进度条
    hotProgressBar = view.findViewById(R.id.hot_progress);
    recommendProgressBar = view.findViewById(R.id.recommend_progress);


    banner = view.findViewById(R.id.banner);
    //设置banner样式
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
    //设置图片加载器
    banner.setImageLoader(new GlideImageLoader());


    hotProductGridView = view.findViewById(R.id.hot_gridview);
    recommendProductGridView = view.findViewById(R.id.recommend_gridview);
    searchView = view.findViewById(R.id.home_serachview);

}
 
Example #5
Source File: HomeFragment.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public void setBanners(List<String> images, List<String> titles, List<String> urls) {
    banner.releaseBanner();
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
    banner.setImageLoader(new GlideImageLoader());
    banner.setImages(images);
    banner.setBannerAnimation(Transformer.Default);
    banner.setBannerTitles(titles);
    banner.isAutoPlay(true);
    banner.setDelayTime(5000);
    banner.setIndicatorGravity(BannerConfig.CENTER);
    banner.setOnBannerListener(position -> {
        String url = urls.get(position);
        String title = titles.get(position);
        Intent intent = new Intent(getContext(), WebViewActivity.class);
        intent.putExtra("title", title);
        intent.putExtra("link", url);
        startActivity(intent);
    });
    banner.start();
}
 
Example #6
Source File: MainActivity.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setTheme(R.style.LaunchScreenTheme);
    setContentView(R.layout.activity_main);

    List<Integer> images = new ArrayList<>();
    TypedArray imgArrays = getResources().obtainTypedArray(R.array.banner_img);
    for (int i = 0; i < imgArrays.length(); i++) {
        images.add(imgArrays.getResourceId(i, 0));
    }
    imgArrays.recycle();

    mImageBanner = findViewById(R.id.image_banner);
    mImageBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR)
            .setImageLoader(new GlideImageLoader())
            .setImages(images)
            .setDelayTime(1500)
            .setIndicatorGravity(BannerConfig.CENTER)
            .setOnBannerListener(this)
            .start();
}
 
Example #7
Source File: HomeFragment.java    From WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void showBannerDatas(List<BannerData> bannerDataList) {
    if(!CommonUtil.isEmptyList(bannerTitles)){
        bannerTitles.clear();
        bannerImages.clear();
        bannerAddress.clear();
    }
    //获得标题,图片
    for (BannerData bannerData : bannerDataList) {
        bannerTitles.add(bannerData.getTitle());
        bannerImages.add(bannerData.getImagePath());
        bannerAddress.add(bannerData.getUrl());
    }
    //设置banner
    mBanner.setImageLoader(new BannerImageLoader())
            .setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)//显示圆形指示器和标题(水平显示)
            .setImages(bannerImages)//设置图片集合
            .setBannerAnimation(Transformer.BackgroundToForeground)//设置轮播动画
            .setBannerTitles(bannerTitles)//设置标题集合
            .setIndicatorGravity(BannerConfig.RIGHT)//设置指示器位置,右边
            .setDelayTime(2000)//设置轮播事件间隔
            .setOnBannerListener(position -> {
                //跳转到详情
                ArticleBean articleBean = new ArticleBean();
                articleBean.setTitle(bannerTitles.get(position));
                articleBean.setLink(bannerAddress.get(position));
                articleBean.setCollect(false);
                articleBean.setId(-1);
                ArticleActivity.startActivity(mActivity, articleBean, true);
            })//设置点击事件,下标从零开始
            .start();
}
 
Example #8
Source File: ThirdFragment.java    From myapplication with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化界面控件
 */
private void initView() {
    mImages.add(R.drawable.find_1);
    mImages.add(R.drawable.find_2);
    mImages.add(R.drawable.find_8);
    mImages.add(R.drawable.find_4);
    mImages.add(R.drawable.find_5);
    mImages.add(R.drawable.find_6);
    mImages.add(R.drawable.find_7);

    mTitles.add("既见公子,云胡不喜?");
    mTitles.add("我只想静静地,做个美男子。");
    mTitles.add("曾经的曾经,只剩期望...");
    mTitles.add("你那么美,爱我如何?");
    mTitles.add("夜,夜,夜...");
    mTitles.add("孩子,快点睡吧,明天还要抢票回家呢。");
    mTitles.add("天边美丽的火烧云啊,我的生活放荡,像条狗,像条流浪狗...");

    titleSearchIbtn = (ImageButton) view.findViewById(R.id.title_find_search_ibtn);
    titleSearchIbtn.setOnClickListener(ThirdFragment.this);

    nineGridView = (NineGridView) view.findViewById(R.id.find_nine_gridview);
    nineGridView.setAdapter(new NineGridViewAdapter(getActivity()));

    mBanner = (Banner) view.findViewById(R.id.banner);
    mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
    mBanner.setBannerAnimation(Transformer.Default);
    mBanner.isAutoPlay(true);
    mBanner.setDelayTime(3000);
    mBanner.setIndicatorGravity(BannerConfig.CENTER);
    mBanner.setBannerTitles(mTitles);
    mBanner.setImageLoader(new GlideImageLoader());
    mBanner.setImages(mImages);
    mBanner.start();
    mBanner.setOnBannerClickListener(this);
}
 
Example #9
Source File: MainFragment.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化广告图片
 */
private void initBanner() {
    //设置图片加载器
    banner.setImageLoader(new GlideImageLoader());
    //设置banner样式
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
}
 
Example #10
Source File: NewsListRecyclerViewAdapter.java    From BaoKanAndroid with MIT License 5 votes vote down vote up
/**
 * 配置recyclerView头部轮播
 */
private void setupRecyclerViewHeader(Banner banner) {

    List<String> images = new ArrayList<>();
    List<String> titles = new ArrayList<>();

    for (ArticleListBean bean :
            isGoodArticleBeans) {
        images.add(bean.getTitlepic());
        titles.add(bean.getTitle());
    }

    banner.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (SizeUtils.getScreenHeightPx(context) * 0.3)));

    // 配置banner
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
            .setImageLoader(new FrescoImageLoader())
            .setImages(images)
            .setBannerTitles(titles)
            .isAutoPlay(true)
            .setDelayTime(5000)
            .setBannerAnimation(Transformer.Default)
            .setIndicatorGravity(BannerConfig.RIGHT)
            .start();

    // 监听banner点击事件
    banner.setOnBannerClickListener(new OnBannerClickListener() {
        // position 从1开始
        @Override
        public void OnBannerClick(int position) {
            if (onItemTapListener != null) {
                onItemTapListener.onItemTapListener(isGoodArticleBeans.get(position - 1));
            }
        }
    });

}
 
Example #11
Source File: NewsListRecyclerViewAdapter.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
/**
 * 配置recyclerView头部轮播
 */
private void setupRecyclerViewHeader(Banner banner) {

    List<String> images = new ArrayList<>();
    List<String> titles = new ArrayList<>();

    for (ArticleListBean bean :
            mIsGoodArticleBeans) {
        images.add(bean.getTitlepic());
        titles.add(bean.getTitle());
    }

    banner.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (SizeUtils.getScreenHeightPx(mContext) * 0.3)));

    // 配置banner
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
            .setImageLoader(new FrescoImageLoader())
            .setImages(images)
            .setBannerTitles(titles)
            .isAutoPlay(true)
            .setDelayTime(5000)
            .setBannerAnimation(Transformer.Default)
            .setIndicatorGravity(BannerConfig.RIGHT)
            .start();

    // 监听banner点击事件
    banner.setOnBannerClickListener(new OnBannerClickListener() {
        // position 从1开始
        @Override
        public void OnBannerClick(int position) {
            if (mOnItemTapListener != null) {
                mOnItemTapListener.onItemTapListener(mIsGoodArticleBeans.get(position - 1));
            }
        }
    });

}
 
Example #12
Source File: HomeFragment.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
/**
 * 轮播图数据
 */
private void setBannerData() {
    //设置图片集合
    mBanner.setImages(images);
    //设置标题集合(当banner样式有显示title时)
    mBanner.setBannerTitles(titles);

    //设置指示器位置(当banner模式中有指示器时)
    mBanner.setIndicatorGravity(BannerConfig.CENTER);
    mBanner.start();
}
 
Example #13
Source File: HomeFragment.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mToolBar.setOnClickListener(this);
    //设置banner样式
    mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
    //设置图片加载器
    mBanner.setImageLoader(new GlideImageLoader());
}
 
Example #14
Source File: ImmersionActivity.java    From AndroidQuick with MIT License 5 votes vote down vote up
@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 #15
Source File: MainPagerFragment.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void showBannerData(List<BannerData> bannerDataList) {
    mBannerTitleList = new ArrayList<>();
    List<String> bannerImageList = new ArrayList<>();
    mBannerUrlList = new ArrayList<>();
    for (BannerData bannerData : bannerDataList) {
        mBannerTitleList.add(bannerData.getTitle());
        bannerImageList.add(bannerData.getImagePath());
        mBannerUrlList.add(bannerData.getUrl());
    }
    //设置banner样式
    mBanner.setBannerStyle(BannerConfig.NUM_INDICATOR_TITLE);
    //设置图片加载器
    mBanner.setImageLoader(new GlideImageLoader());
    //设置图片集合
    mBanner.setImages(bannerImageList);
    //设置banner动画效果
    mBanner.setBannerAnimation(Transformer.DepthPage);
    //设置标题集合(当banner样式有显示title时)
    mBanner.setBannerTitles(mBannerTitleList);
    //设置自动轮播,默认为true
    mBanner.isAutoPlay(true);
    //设置轮播时间
    mBanner.setDelayTime(bannerDataList.size() * 400);
    //设置指示器位置(当banner模式中有指示器时)
    mBanner.setIndicatorGravity(BannerConfig.CENTER);

    mBanner.setOnBannerListener(i -> JudgeUtils.startArticleDetailActivity(_mActivity, null,
            0, mBannerTitleList.get(i), mBannerUrlList.get(i),
            false, false, true));
    //banner设置方法全部调用完毕时最后调用
    mBanner.start();
}
 
Example #16
Source File: HomeAdapter.java    From playa with MIT License 5 votes vote down vote up
@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 #17
Source File: HomeFragment.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void showBannerData(List<BannerData> bannerDataList) {
    if (!CommonUtils.isEmptyList(bannerTitles)) {
        bannerTitles.clear();
        bannerImages.clear();
        bannerUrls.clear();
    }

    //获得标题,图片
    for (BannerData bannerData : bannerDataList) {
        bannerTitles.add(bannerData.getTitle());
        bannerImages.add(bannerData.getImagePath());
        bannerUrls.add(bannerData.getUrl());
    }
    //设置banner
    banner.setImageLoader(new BannerImageLoader())
            .setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)//显示圆形指示器和标题(水平显示)
            .setImages(bannerImages)//设置图片集合
            .setBannerAnimation(Transformer.Default)//设置轮播动画
            .setBannerTitles(bannerTitles)//设置标题集合
            .setIndicatorGravity(BannerConfig.RIGHT)//设置指示器位置,右边
            .setDelayTime(3000)//设置轮播事件间隔
            .setOnBannerListener(position -> {
                ArticleActivity.startActivityByFragment(mActivity,
                        this,
                        bannerUrls.get(position),
                        bannerTitles.get(position));
            })//点击事件
            .start();
}
 
Example #18
Source File: WelcomeActivity.java    From HomeApplianceMall with MIT License 4 votes vote down vote up
@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 #19
Source File: HomeFragment2.java    From iMoney with Apache License 2.0 4 votes vote down vote up
@Override
protected void initData(String content) {
    if (!TextUtils.isEmpty(content)) {
        // 1.使用fastJson解析数据,并封装数据到java对象中
        JSONObject jsonObject = JSON.parseObject(content);
        String proInfo = jsonObject.getString("proInfo");
        Product product = JSON.parseObject(proInfo, Product.class);

        String imageArr = jsonObject.getString("imageArr");
        List<Image> images = JSON.parseArray(imageArr, Image.class);

        index = new Index();
        index.product = product;
        index.images = images;

        // 2.设置Banner,加载显示图片
        // 设置banner样式
        banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
        // 设置图片加载器
        banner.setImageLoader(new ImageLoader() {
            @Override
            public void displayImage(Context context, Object path, ImageView imageView) {
                // Picasso加载图片简单用法
                Picasso.with(context).load((String) path).into(imageView);
            }
        });
        // 设置图片url集合:imageUrl
        List<String> imageUrl = new ArrayList<String>(images.size());
        for (int i = 0; i < images.size(); i++) {
            imageUrl.add(images.get(i).IMAURL);
            Log.e("TAG", "url = " + images.get(i).IMAURL);
        }
        banner.setImages(imageUrl);
        // 设置banner动画效果
        banner.setBannerAnimation(Transformer.ZoomOutSlide); // DepthPage
        // 设置标题集合(当banner样式有显示title时)
        String[] titles = new String[]{"深情不及久伴,加息2%", "乐享活计划", "破茧重生", "安心钱包计划"};
        banner.setBannerTitles(Arrays.asList(titles));
        // 设置自动轮播,默认为true
        banner.isAutoPlay(true);
        // 设置轮播时间
        banner.setDelayTime(3000);
        // 设置指示器位置(当banner模式中有指示器时)
        banner.setIndicatorGravity(BannerConfig.RIGHT);
        // banner设置方法全部调用完毕时最后调用
        banner.start();

        // 3.根据得到的产品的数据,更新界面中的产品展示
        String yearRate = index.product.yearRate;
        tvHomeRate.setText(yearRate + "%");

        currentProgress = Integer.parseInt(index.product.progress);
        new Thread(runnable).start();
    }
}
 
Example #20
Source File: HomeFragment.java    From HomeApplianceMall with MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_home, container, false);
    canRefresh = true;
    first = true;
    application = (MyApplication)getActivity().getApplication();
    gridView = (MyGridView) v.findViewById(R.id.GridView_fhome);
    gridViewToday = (MyGridView) v.findViewById(R.id.GridView_fhome_today);
    gridViewSale = (MyGridView) v.findViewById(R.id.GridView_fhome_sale);
    gridViewNew = (MyGridView) v.findViewById(R.id.GridView_fhome_new);

    List<Integer> images = new ArrayList<>();
    images.add(R.drawable.adv_1);
    images.add(R.drawable.adv_2);
    images.add(R.drawable.adv_3);
    List<String> titles = new ArrayList<>();
    titles.add("地一个");
    titles.add("第二个");
    titles.add("第三个");
    Banner banner = (Banner) v.findViewById(R.id.homeBanner);
    //设置banner样式
    banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
    //设置图片加载器
    banner.setImageLoader(new GlideImageLoader());
    //设置图片集合
    banner.setImages(images);
    //设置banner动画效果
    banner.setBannerAnimation(Transformer.Accordion);
    //设置自动轮播,默认为true
    banner.isAutoPlay(true);
    //设置轮播时间
    banner.setDelayTime(1100);
    //设置指示器位置(当banner模式中有指示器时)
    banner.setIndicatorGravity(BannerConfig.CENTER);
    //banner设置方法全部调用完毕时最后调用
    banner.start();

    initMenuList();
    todayList = new ArrayList<>();
    saleList = new ArrayList<>();
    newList = new ArrayList<>();
    MyAdapter myAdapter = new MyAdapter(this.getContext(),menuList);
    myAdapterForToday = new MyAdapterForGoods(this.getContext(),todayList);
    myAdapterForSale = new MyAdapterForGoods(this.getContext(),saleList);
    myAdapterForNew = new MyAdapterForGoods(this.getContext(),newList);
    gridView.setAdapter(myAdapter);
    gridViewToday.setAdapter(myAdapterForToday);
    gridViewSale.setAdapter(myAdapterForSale);
    gridViewNew.setAdapter(myAdapterForNew);
    ac = new LoginAC();
    return v;
}