Force RecyclerView to redraw its items

后端 未结 9 1180
闹比i
闹比i 2021-02-02 06:45

Is there any way to redraw all items of RecyclerView?

I have some Themes (in style.xml) and after changing the theme, I need the RecyclerView t

9条回答
  •  悲哀的现实
    2021-02-02 07:25

    Simply setting recyclerview's adapter again worked for me (I wanted RecyclerView to redraw all items' layout again)

    /**
     * Forces RecyclerView adapter to call createViewHolder() - i.e. redraw all all items' layouts
     */
    private fun resetAdapterState() {
        val myAdapter = recyclerView.adapter
        recyclerView.adapter = myAdapter
    }
    

提交回复
热议问题