CodePudding user response:
Try this
searchItemList.clear()
linearLayoutManager?.removeAllViews()
binding.accessoryRecyclerView.removeAllViews()
adapter.differ.submitList(null)
postViewModel.finalURL.value =
BASE_URL_POSTS_BY_LABEL "posts?labels=Accessory&key=$API_KEY"
requestApiData()
CodePudding user response:
Simply create a function named clearList in your custom adapter class. get list object and call .clear() function on it. Then call notifyDataSetChanged() and you are good to go.