Comments (10)
bindview是不会加载多次的,你可以试试你放入100条数据,你就放一个item,然后看看log的数目是多少,可以尝试一下,如果仍旧是100次,那么就是我的严重失误了。咱们可以一起来看看
from commonadapter.
我稍微所以下我是怎么用的:
AdapterItem:
@Override
public int getLayoutResId() {
return R.layout.item_note;
}
@Override
public void bindViews(View view) {
KLog.w();//打Log
x.view().inject(this, view);//注入
}
@Override
public void handleData(Note note, int i) {
tv_title.setText(note.getName());
}
Fragment:
private CommonAdapter<Note> noteAdapter = new CommonAdapter<Note>(null, 1) {
@NonNull
@Override
public AdapterItem createItem(Object o) {
return new NoteItem();
}
};
......
//加载到数据
mListView.setAdapter(noteAdapter);
noteAdapter.setData(taskNotes);
noteAdapter.notifyDataSetChanged();
from commonadapter.
嗯,好。然后看log
from commonadapter.
04-08 10:10:36.008 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.018 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.038 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.058 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.078 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
04-08 10:10:36.088 26640-26640/com.andecy.exercise W/NoteItem.java: [ (NoteItem.java:48)#BindViews ] execute
from commonadapter.
总共有6条数据,bindVIews执行了6次
from commonadapter.
你放100条。
from commonadapter.
好吧,意思是说这个bindViews会执行屏幕允许的item数量的次数吗?
from commonadapter.
那这样的话,也会有一定性能上的影响吧,比如一个页面有十几个item的(不知道gridview会不会这样)
from commonadapter.
是的,这个是listview本身的复用逻辑。这个和性能无关,这是必须的。我给你发一个我写的简单介绍,你看看就明白了:http://www.cnblogs.com/tianzhijiexian/p/4769959.html
from commonadapter.
恍然大悟,非常感谢耐心解答!
from commonadapter.
Related Issues (20)
- 缺少ExRcvAdapterWrapper HOT 1
- test
- 请问如何去获取点击item所对应的数据? HOT 2
- RecyclerView MemoryLeak HOT 5
- 如何动态的设置List来实现更多加载或者上拉刷新功能 HOT 1
- RecyclerView加载数据显示不完全。 HOT 7
- ViewHolder中的item问题 HOT 5
- 增加recycleview或者adapter上的item的clicklistener,并且要能和item内部的监听器共存 HOT 1
- 如何更新Item构造函数中传入的的非泛型数据呢? HOT 4
- RecycleView RecycleViewPool 中存在内存泄漏,每次显示时候RecycleViewPool 中RcvAdapterItem会增加。 HOT 10
- 为什么在Scrollview 里面 嵌套 recyclerview 的时候,使用这个CommonAdapter的话,recyclerview 是可以正常展示的呢? HOT 5
- 依赖失败 HOT 4
- 没有loadingmore的api么 HOT 1
- debug版本无法运行 HOT 2
- 2.2.1 依赖失败 HOT 3
- setHeaderView 横向滚动支持,内部类包权限限制方法重写 HOT 2
- Eclips
- Eclips怎么使用?有jar包吗? HOT 1
- 我这样做 item局部刷新 发现布局还是会复用 出现状态重复显示的ui HOT 1
- 添加头部后,无法动态remove掉 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonadapter.