以下是我的回收視圖實施。刷新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相當滯後......! –