Giter Club home page Giter Club logo

singleselectgrid's Introduction

使用场景

1.当你觉得用GridView去实现单选功能有些麻烦。
2.当你的单选布局需要与其他可滑动控件(如ListView)嵌套使用,而你又不想花时间解决滑动兼容问题。 ###效果预览 preview ###XML布局

<com.android.yzl.lib.SingleSelectGrid
        android:id="@+id/ssg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:columnNum="4"
        app:itemHeight="120dp" />

###设置适配器

SingleSelectGrid ssg = (SingleSelectGrid) findViewById(R.id.ssg);
        ssg.setAdapter(new SingleSelectGrid.SingleSelectGridAdapter() {
            @Override
            public int getCount() {
                return 12;
            }

            @Override
            public View getView(int pos, ViewGroup parent) {
                View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.item_ssg, parent, false);
                return view;
            }

            @Override
            public void onSelect(int pos, View v, View lastSelectItem) {
                Toast.makeText(MainActivity.this, "" + pos, Toast.LENGTH_SHORT).show();
            }
        });

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.