recyclerView 记录一个问题

2020-12-23  本文已影响0人  菜鸟何时起飞

1 setAdapter
据说会标记所有的数据都为无效数据重新绑定新的数据

2 swapAdapter

 /**
     * Swaps the current adapter with the provided one. It is similar to
     * {@link #setAdapter(Adapter)} but assumes existing adapter and the new adapter uses the same
     * {@link ViewHolder} and does not clear the RecycledViewPool.
     * <p>
     * Note that it still calls onAdapterChanged callbacks.
     *
     * @param adapter The new adapter to set, or null to set no adapter.
     * @param removeAndRecycleExistingViews If set to true, RecyclerView will recycle all existing
     *                                      Views. If adapters have stable ids and/or you want to
     *                                      animate the disappearing views, you may prefer to set
     *                                      this to false.
     * @see #setAdapter(Adapter)
     */

要求是布局要一样活着类似 如果布局不一样复用的时候会出现转换异常的问题

上一篇 下一篇

猜你喜欢

热点阅读