Home > Blockchain >  Remove AsyncListDiffer list and update it after click close search (submit null not working)
Remove AsyncListDiffer list and update it after click close search (submit null not working)

Time:09-09

In this app I am using

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.

  • Related