So basically i have 4 fragments I'm currently working on second. I have some weird situation here. When app started it open fragment on position 1 then if I navigate to fragment 2 via tabs on top fragment 2 will update, then if I open fragment 3 from fragment 2 and return to fragment 2 from fragment 3 it will also update. But if I choose to open fragment 4 and then return to fragment 2 it won't refresh. This is method that I'm calling to refresh fragment
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
loadEvents();
}
Log.d("TAG", "VISIBLE");
}
in LoadEvents there are few recyclerview setting their adapters. Nothing speciall
I think it is because when you call fragment 3 and when you return to the fragment 2 you use .replace
, instead when you go to the fragment 4 you use .add
and to return to the fragment 2 .show
.
looks at the differences between:
https://developer.android.com/reference/android/app/FragmentTransaction.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.