Giter Site home page Giter Site logo

commonadapter's Introduction

CommonAdapter

   设计思路:
          1.巧妙的利用java泛型技术,使得数据源的适配可以拥抱变化。
          2.把adapter的item作为了一个实体对象,这种方式借鉴了RecyclerView的ViewHolder的设计。
   优点:
          1.简化Adapter的实现
          2.对象化Item,高度解耦,更加灵活

Usage

for Maven

<dependency>
 <groupId>com.ioter</groupId>
 <artifactId>adapter</artifactId>
 <version>1.1.4</version>

pom

for Gradle

compile 'com.ioter:adapter:1.1.4'

How to use?

   1. 把adapter作为子module引入到项目中;
   2.在主module的build.gradle文件中加入如下引用:
   compile ‘com.jakewharton:butterknife:7.0.1’(因为adapter里的view采用此组件进行注入的);
   3. new CommonAdapter复写getItemView方法,如下:
   listView.setAdapter(new CommonAdapter<ModelBean>(data) {
   @NonNull    
    @Override    
   public AdapterItem<ModelBean> getItemView(Object type) {
                 return new TextItem();   
          }
   });

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.