comcp / android-stupid-adapter Goto Github PK
View Code? Open in Web Editor NEW只关注开发效率,
License: Apache License 2.0
只关注开发效率,
License: Apache License 2.0
提出几点建议
ViewHolder也可以封装,考虑SparseArray,用成员变量存和用Map存本质上一样
adapter本身不必提供管理list的接口,完全没必要
OnItemClickListener建议废弃,容易出很多bug,直接在adapter里控制点击事件也不违背任何原则
convertView的复用封装起来了吗?没注意到
基本上这个库可以简化成两个类,并且二者除了基类不一样,其他都一样,对应ListView和Recyclerview的adapter
extend XViewHolder<Bean>{
@Override
public void onResetView(Bean arg0, int arg1) {
switch(arg0.getType()){
case 1:
case 2:
}
}
}
我现在的做法是在Bean里加一个type字段,来进行区分,
将所有可能的布局都写到一个xml里,用ViewStub 进行动态载入;
或者是
extend XViewHolder<Object>{
@Override
public void onResetView(Object arg0, int arg1) {
if(arg0 instanceof String){
}else if(arg0 instanceof Integer){
}
}
}
在 viewHolder里的onCreate里进行设置
将所有的点击事件的参数都传递为this,
这样就可以在外部的activity里进行操作.
参考demo里的模仿微信聊天界面哪里
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.