RecyclerView change data set

前端 未结 5 2070
一个人的身影
一个人的身影 2020-12-07 11:33

I want to implement search functionality for my RecyclerView. On text changed i want to change the data that are displayed with this widget. Maybe this question has been ask

5条回答
  •  无人及你
    2020-12-07 11:53

    This is my answer - thanks to Ivan Skoric from his site: http://blog.lovelyhq.com/creating-lists-with-recyclerview-in-android/

    I created an extra method inside my adapter class:

    public void updateList(List data) {
        mData = data;
        notifyDataSetChanged();
    }
    

    Then each time your data changes, you just call this method passing in your new data and your view should change to reflect it.

提交回复
热议问题