Commonadapter

通用 RecyclerView 适配器,用最少的代码使用 Adapter
Alternatives To Commonadapter
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Baseadapter4,646
2 years ago112apache-2.0Java
Android 万能的Adapter for ListView,RecyclerView,GridView等,支持多种Item类型的情况。
Flipviewpager.draco1,845
4 years ago6Java
This project aims to provide a working page flip implementation for usage in ListView.
Asymmetricgridview1,724
365 years ago3July 01, 201533mitJava
Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span
Renderers1,2128872 years ago22May 20, 20202apache-2.0Java
Renderers is an Android library created to avoid all the boilerplate needed to use a RecyclerView/ListView with adapters.
Multichoiceadapter865529 years ago11February 25, 201411apache-2.0Java
Android - A ListView adapter with support for multiple choice modal selection
Pinnedheaderlistview676
8 years ago25Java
A ListView with pinned section headers for Android
Superadapter636
6 years agoJava
[Deprecated]. 🚀 Adapter(BaseAdapter, RecyclerView.Adapter) wrapper for Android. 一个Adapter同时适用RecyclerView、ListView、GridView等。
Android Arsenal.com532
3 years ago2HTML
Source to android-arsenal.herokuapp.com
Android_5.0_viewdemo481
4 years ago5Java
一些基于 Android 5.0/6.0/N 新特性的小案例
Verticalbannerview436
7 years agoJava
a vertical banner view in android.you can find it in 淘宝app、京东app...
Alternatives To Commonadapter
Select To Compare


Alternative Project Comparisons
Readme

CommonAdapter

Build Status Jitpack Apache 2.0

中文介绍

  • [x] A common ListView / RecyclerView adapter.
  • [x] Support RecyclerView multiple view type. This is a demo

Intro

Sample Download

Get it on Google Play

Setup

allprojects {
  repositories {
    // ...
    maven { url "https://jitpack.io" }
  }
}
implementation "com.github.twiceyuan.CommonAdapter:library:$latest_version"
implementation "com.github.twiceyuan.CommonAdapter:kotlin-extension:$latest_version"

(ext.latest_version= Jitpack)

Usage

  1. create a ViewHolder extends CommonHolder<T>,T is a model class
// bind layout id
@LayoutId(R.layout.item_person)
public class PersonHolder extends CommonHolder<Person> {

    // bind View id
    @ViewId(R.id.name) TextView name;
    @ViewId(R.id.email) TextView email;

    // bind data
    @Override public void bindData(Person person) {
        name.setText(person.name);
        email.setText(person.email);
    }
}
  1. Create a common adapter and call setAdapter method of list view or recycler view.

    RecyclerView Adapter

    // build adapter
    CommonAdapter<Person, PersonHolder> recyclerAdapter = new CommonAdapter<>(this, PersonHolder.class);
    
    // set adapter
    mRecyclerView.setAdapter(recyclerAdapter);
    

    ListView Adapter

    // build adapter
    CommonListAdapter<Person, PersonHolder> listAdapter = new CommonListAdapter<>(this, PersonHolder.class);
    mListView.setAdapter(listAdapter);
    

    Setup listener (by holder)

    recyclerAdapter.setOnBindListener((position, person, holder) -> {
        // holder is used to bind event listener
        holder.name.setOnClickListener((v) -> toast(person.name));
        holder.email.setOnClickListener((v) -> toast(person.email));
    });
    

Proguard

-keepattributes *Annotation*
-keepclassmembers class * extends com.twiceyuan.commonadapter.library.holder.CommonHolder {
    public <init>(...);
}

Thanks

License

Copyright 2016 twiceYuan.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Popular Adapter Projects
Popular Listview Projects
Popular Libraries Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Java
Adapter
Listview
Proguard
Viewholder