以下是我的回收视图实施。刷新RecyclerView适配器每1秒
回收站视图令人耳目一新,但视图滞后,无法顺利滚动。 如果我不刷新数据recyclerView是光滑的。 问题是只有刷新.. !!
我需要在RecyclerView中每1秒钟完全刷新一次数据,并保持相同的滚动位置。
XML
<android.support.v7.widget.RecyclerView
android:id="@+id/recyView_disp_pgms"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null" />
活动:
RecyclerView recyView_disp_pgms = (RecyclerView) findViewById(R.id.recyView_disp_pgms);
DisplayProgramsAdapterRecycler pgmAdapter = new DisplayProgramsAdapterRecycler(programsList);
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
recyView_disp_pgms.setLayoutManager(layoutManager);
recyView_disp_pgms.setAdapter(pgmAdapter);
handler = new Handler();
runnable = new Runnable() {
@Override
public void run() {
System.out.println("AllPgm Runflag : " + runflag);
programList = // Get List from database
if (programsList != null && programsList.size() > 0) {
if (pgmAdapter != null && pgmAdapter.getItemCount() > 0) {
pgmAdapter.resetData(programsList);
}
}
handler.postDelayed(this, 1000);
}
};
handler.post(runnable);
适配器:
public void resetData(ArrayList<ProgramDetails_Table> programsList) {
this.programDetailsList = programsList;
this.notifyDataSetChanged();
}
问题 - 仅在每1秒更新一次数据时,回收站的滚动视图才会丢失
尝试关注其他帖子;但仍然没有运气。 请帮助.. !!
你说'回收者视图令人耳目一新'。那么你想在这里做什么? – UmarZaii
我想让recyclerview滚动平滑;截至目前它的刷新列表每1秒和recyclerview相当滞后......! –