国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 更新RecyclerView的好方法

2019-12-12 02:40:59
字體:
來源:轉載
供稿:網友

一般在使用RecyclerView的時候不免要修改RecyclerView的數據,使用notifyDataSetChanged()來刷新界面,但是當數據比較多,而只是修改了一點的數據,或者刷新比較頻繁,這樣就會導致界面的卡頓問題,用戶交互特別不好。

  這個時候就需要只是修改需要修改的數據,不要將數據全部進行更新,這樣就可以解決問題。

  局部更新的代碼如下:

private int position;//當前recyclerview的position@BindView(R.id.speak_valuate_recycler_view)RecyclerView recyclerView;private LinearLayoutManager mRecyclerViewLayoutManager;mRecyclerViewLayoutManager = new LinearLayoutManager(this);mRecyclerViewLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);recyclerView.setLayoutManager(mRecyclerViewLayoutManager);private void changVolume(final int volume) {    int first = mRecyclerViewLayoutManager.findFirstVisibleItemPosition();    int last = mRecyclerViewLayoutManager.findLastVisibleItemPosition();    if (position >= first && position <= last) {      View view = recyclerView.getChildAt(position - first);      if (recyclerView.getChildViewHolder(view) instanceof SpeakContentAdapter.SpeakContentHolder) {        //修改數據        ProgressImageView progressImageView = (ProgressImageView) view.findViewById(R.id.speak_item_record);        progressImageView.setProgress(volume);      }    }  }    

以上所述是小編給大家介紹的Android 更新RecyclerView的好方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 冷水江市| 九台市| 东至县| 白水县| 裕民县| 芜湖市| 西宁市| 沧州市| 慈利县| 大城县| 荔波县| 疏勒县| 桐庐县| 延吉市| 桃园市| 农安县| 松原市| 翼城县| 澳门| 庆元县| 镇江市| 凌海市| 昔阳县| 开远市| 庆城县| 海盐县| 栾川县| 本溪| 齐河县| 曲松县| 大连市| 华坪县| 明水县| 蒙自县| 宜春市| 木里| 铁岭县| 大邑县| 彰武县| 梨树县| 偏关县|