我有layout
,因为BottomSheetLayout
包含RecyclerView
,在我的代码中,我显示了一些图像,这些图像是从API获取的,这是在RecyclerView
中设置适配器的方法。 / p>
private void setAdapterForRecyclerView(final List<Wallpaper> wlls) {
arrayList = wlls;
if (myAdapter == null) {
myAdapter = new MyAdapter(wlls, FullScreen.this, new RecyclerViewClickListener() {
@Override
public void onClick(View view, Wallpaper wallpaper) {
}
@Override
public void onClick(View view, Category categories) {
}
});
recyclerView.setAdapter(myAdapter);
} else {
// int position = myAdapter.getItemCount();
myAdapter.getItems().addAll(wlls);
myAdapter.notifyDataSetChanged();
}
progressbar.setVisibility(View.GONE);
}
我有一个AsyncTask
类,我在其中获取数据并将其存储在ArrayList
@Override
protected void onPostExecute(List<Wallpaper> wallpapers) {
super.onPostExecute(wallpapers);
setAdapterForRecyclerView(wallpapers);
}
我的问题
当我显示BottomSheetLayout
时,一切正常,我看到Recyclerview
中的所有图像,但是当我使用 关闭/关闭时(返回按钮或向下滑动) 并再次显示BottomSheetLayout
,Recyclerview
的所有项目均未显示,要再次显示,我应该完成活动并再次打开它。
我尝试过的方法:
bottomSheet.addOnSheetDismissedListener(new OnSheetDismissedListener() {
@Override
public void onDismissed(BottomSheetLayout bottomSheetLayout) {
arrayList = myAdapter.getItems();
isCancaled = true;
}
});
if (isCancaled) {
setAdapterForRecyclerView(arrayList);
} else {
_fetchDataSimilar.execute();
}
但仍然无法正常工作,请有人可以帮助我