我想刷新列表視圖fragmentA當回壓如何onbackpressed時刷新片段列表視圖()
例如:
我在FragmentA列表視圖中單擊onitem到FragmentB
,當我點擊FragmentB中的(在Activity中),我想刷新 listview FragmentA。
對不起我的英語不好。
如何在FragmentA中設置onViewCreated或onResume ???
和我的活動
@Override
public void onBackPressed() {
super.onBackPressed();
MyFragmentA
@Override
public void setItems(ArrayList<NotificationListModel> items,String last_page) {
Log.d("NotificationFragment", "setItems ");
this.notificationListModels=items;
this.last_page=last_page;
for (NotificationListModel notificationListModel: notificationListModels){
notificationListModelArrayList.add(notificationListModel);
}
getData();
if (getActivity()!=null) {
int currentPosition = getListView().getFirstVisiblePosition();
adapNotificationList = new AdapNotificationList(getActivity(), notificationListModelArrayList);
setListAdapter(adapNotificationList);
adapNotificationList.notifyDataSetChanged();
getListView().setSelection(currentShowList);
getListView().setSelectionFromTop(currentPosition + 1, 0);
}
}
我的代碼我設置了adapter.notifyDataSetChanged();在setItems()中是錯誤的?請檢查我的代碼,我編輯了一篇文章 –