请遵循要点
RecyclerView然后通过监听器更新你的RecyclerView适配器
protected void onListViewUpdate(final int position, final Object object) {
final RecyclerView view = mView;
LinearLayoutManager layoutManager = ((LinearLayoutManager)view.getLayoutManager());
final View convertView = layoutManager.findViewByPosition(position);
int firstVisiblePosition = layoutManager.findFirstCompletelyVisibleItemPosition();
int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
if (firstVisiblePosition <= position && position <= lastVisiblePosition) {
// this is the convertView that you previously returned in getView
// just fix it (for example:)
Thread thread = new Thread(){
@Override
public void run() {
super.run();
runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.updateRow(adapter.getItem(position), convertView, object);
}
});
}
};
thread.start();
} else {
// just update your data set, UI will be updated automatically in next
// getView() call
adapter.updateData(position, object);
}
}
Run Code Online (Sandbox Code Playgroud)从适配器中更新当前可见视图的updateRow()方法。
任务完成 :)
| 归档时间: |
|
| 查看次数: |
2579 次 |
| 最近记录: |