Why RecyclerView items disappear with scrolling

后端 未结 5 872
无人共我
无人共我 2020-12-10 08:36

I am using a RecyclerView in my app but when I scroll on my RecyclerView my items will disappear! I used this code for a lot of RecyclerView but this time I don\'t know what

5条回答
  •  余生分开走
    2020-12-10 08:57

    To hide certain views with multiple items, it is better to hide the base layout by,

    1. Give an id to the base layout of the view in XML. 
    2. Define the view inside your "RecyclerViewAdapter class"
    LinearLayout mItems_timelineId;
    mItems_timelineId = itemView.findViewById(R.id.items_timelineId);
    3. Then remove the view wherever you wish to by,
    mItems_timelineId.removeAllViews();
    

    This is worked for me. Thank you.

提交回复
热议问题