My application consists of several tabs which all contain ListViews which are in a Fragment. These ListViews are populated using one class. I use a variable called current tab in order to detect which tab is selected and therefore the ListView can be populated to fit its requirements.
I have realised however, that when a tab is selected. The previous and next one are also loaded in order to increase the UI fluidity. I am currently unable to distinguish which listview is being operated on. As a result I am not able to retrieve its corresponding data.
onTabSelected will not do the job. I am wondering if there is some other function/method that will allow me to do this.
You can try to override setUserVisibleHint:
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if(isVisibleToUser){
//called when fragment is visible to the user.
}
}
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.