Giter Club home page Giter Club logo

gridviewpager's Introduction

GridViewPager

原文的博客:Android 仿美团网,探索使用ViewPager+GridView实现左右滑动查看更多分类的功能


原先的布局代码是写在activity_main中的,我做的也就是将它作为library独立做成一个自定义控件,并优化了图片加载的逻辑而已。一点微小的工作。 实现的效果图与原来一模一样 ###使用:

//使用builder模式设计初始化
mGridViewPager
    //设置每一页的容量
    .setPageSize(9)
    .setImageSetListener(new ImageSetListener() {
        @Override
        public void setImage(ImageView iv, int pos) {
            //图片加载方式任选
            iv.setBackgroundResource(mImgRes.get(pos));
        }
    })
    .setGridItemClickListener(new GridItemClickListener() {
        @Override
        public void click(int pos, int position, String str) {
            Log.d("123", pos + "/" + str);
        }
    })
    .setGridItemLongClickListener(new GridItemLongClickListener() {
        @Override
        public void click(int pos, int position, String str) {
            Log.d("456", pos + "/" + str);
        }
    })
    //传入String的List 必须作为最后一步
    .init(initData());

image

gridviewpager's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.