Leanback BrowseFragment 刷新

405 阅读1分钟

1.更新ArrayObjectAdapter

The BrowseFragment use an ArrayObjectAdapter to display data. We just need to:

  1. clear the items of the adapter (clear)
  2. add new items to the adapter(addAll) 这种方法的缺点是刷新是屏幕会闪一下。

2.自定义Adapter

public void replaceAll(Collection items){
    int itemsCount = items.size();
    if (itemsCount == 0){
        return;
    }
    mItems.clear();
    mItems.addAll(index, items);
    notifyItemRangeChanged(0, itemsCount);
}

How to refresh the Android Tv BrowseFragment ?