How to update fragment's data used in ViewPager? View is not showing the updated data

前端 未结 1 545
执念已碎
执念已碎 2020-12-20 00:54

I know the same question has been asked so many times but I am not able to solve my issue.

I have created an Activity which has a ViewPager

1条回答
  •  一向
    一向 (楼主)
    2020-12-20 01:00

    After checking your code more in details i see you do not require to re-initliaze your MediaAdapter inside updateData method.

    You simply require to update your updateData as

    listMedia.clear();
    this.listMedia.addAll(listMedia);
    mediaAdapter.notifyDatasetChanged();
    

    This will reload your data in gridview. Change i suggested will refresh the data in your arraylist which is being used for rendering gridview and then you notify your mediaAdapter to reload the list.

    0 讨论(0)
提交回复
热议问题