Determine if the current fragment is visible
Public abstract class Basefragment extends Fragment {
/**/protected boolean isVisible; @Overridepublicvoid Setuservisiblehint (Boolean isvisibletouser) { super.setuservisiblehint (isvisibletouser); if (Getuservisiblehint ()) { true; Else { false; }}
}
The fragment lifecycle interacts with the activity life cycle.
The life cycle of an activity that has fragment directly affects the life cycle of the fragment, so that callbacks for each life cycle of the activity have a similar callback for fragment. For example, when activity receives a onpause () callback, each fragment in the activity receives a onpause () callback.
Multi-screen fit-if you want to develop an app on Android, you have to consider the problem of fragmentation, or you must consider a multi-screen adaptation.
Note: According to the requirements, judge the current fragment, and then go to request data or other operations
Second, there are times, we use the form of tablayout+fragment, in a certain fragment network request operation, go to other pages to switch back and forth when the network request, then we just add a boolean tag variable, the request after the end of the change tag, Make a judgment on the network request, it will not repeat the request.
Android determines whether the current fragment is visible (visible)