Giter Club home page Giter Club logo

demo4expandablegridview's Introduction

Demo4ExpandableGridView

ExpandableGridView

expandable_gridview.gif

忘记把鼠标录进来,点击事件和**一样。。。 下面是分割线

<dependency> 
    <groupId>com.linyuzai</groupId>   
    <artifactId>expandablegridview</artifactId> 
    <version>1.2.0</version> 
    <type>pom</type>
</dependency>
------------------------------------------------
compile 'com.linyuzai:expandablegridview:1.2.0'
<com.linyuzai.expandablegridview.ExpandableGridView 
    xmlns:grid="http://schemas.android.com/apk/res-auto"    
    android:id="@+id/egv"    
    android:layout_width="match_parent"    
    android:layout_height="wrap_content"    
    grid:group_clickable="true"    
    grid:horizontal_spacing="10dp"    
    grid:overwrite_measure="true"    
    grid:vertical_spacing="10dp" />

horizontal_spacing和vertical_spacing是GridView的属性,然后overwrite_measure,比如在外面套了一个ScrollView就不用自己重写了。如果group_clickable设为了false,发现ChildView不显示,点击也没用,调用一下ExpandableGridView.expandAll();接下来是Adapter~

public ExpandableGridAdapter getExpandableGridAdapter();

public void setExpandableGridAdapter(ExpandableGridAdapter adapter);

class MyAdapter1 extends ExpandableGridAdapter {    
    @Override    
    public int getGridGroupCount() {        
        return 0;    
    }    

    @Override    
    public int getGridChildCount(int gridGroupPosition) {        
        return 0;    
    }    
    
    @Override    
    public View getGridGroupView(int gridGroupPosition, boolean isExpanded, View convertView, ViewGroup parent) {        
        return null;    
    }    

    @Override    
    public View getGridChildView(int gridGroupPosition, int gridChildPosition, View convertView, ViewGroup parent) {        
        return null;    
    }    

    @Override    
    public int getNumColumns(int gridGroupPosition) {        
        return 0;    
    }
}

class MyAdapter2 extends SimpleExpandableGridAdapter<String> {    
    public MyAdapter(List<List<String>> dataList) {        
        super(dataList);    
    }
    
    @Override    
    public View getGridGroupView(int gridGroupPosition, boolean isExpanded, View convertView, ViewGroup parent) {       
        return convertView;    
    }    

    @Override    
    public View getGridChildView(int gridGroupPosition, int gridChildPosition, View convertView, ViewGroup parent) {        
        return convertView;    
    }    

    @Override    
    public int getNumColumns(int gridGroupPosition) {        
        return 0;    
    }
}

最后还有一个

public void setOnGridItemClickListener(OnGridItemClickListener listener);

demo4expandablegridview's People

Contributors

linyuzai avatar

Watchers

 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.