Giter Club home page Giter Club logo

multitypelistviewadapter's Introduction

MultiTypeListViewAdapter: Android ListView Adapter 封装

背景

  • Adapter实现多type的模式,代码不便于维护
  • 希望针对Item粒度的复用
  • ViewHolder的统一封装

封装思路

抽象出独立的ListItem,实现通用的BaseListAdapter/BaseRecyclerAdapter,支持多type,支持ViewHolder

特点

  1. 基于ListItem 的复用,item的数据和代码更加内聚,提高可维护性.
  2. 支持多种类型Item同时使用.
  3. 支持同时存在多种Model类型,由具体的Item确定. Model支持子类和接口实现。
  4. 支持ListView, RecyclerView

Install

  1. 在工程根目录的build.gradle中添加JitPack仓库地址 (注意:是在allprojects节点下)
allprojects {
 repositories {
    jcenter()
    maven { url "https://jitpack.io" }
 }
}
  1. 在用到的module中添加依赖,最新版本查看 Release
dependencies {
    compile 'com.github.kmfish:MultiTypeListViewAdapter:0.1.0'
}

Example

参考

部分实现参考了 CommonAdapter, ,由于考虑到多type的场景下,必然data的类型也是多种的,所以支持了不同类型的data.另外item也可以持有当前显示的data对象,这样方便实现点击事件之后的需求. 同时提供了ArrayAdapter的类似接口,方便数据的增减.

multitypelistviewadapter's People

Contributors

kmfish avatar

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.