我需要我的片段总是调用某个功能时,他们是活跃的片段,所以我把它的onResume(),但它不会被调用。
片段A
@Override
public void onResume(){
super.onResume();
Log.d("clear state", " "+clear);
if(clear == true)
{
restart();
clear = false;
calculate();
}
}
我用FragmentPagerAdapter与ViewPager切换片段
public class ScoutingFragSingle extends FragmentPagerAdapter{
@Override
public Fragment getItem(int index) {
Bundle data = new Bundle();
switch(index){
case 0:
TeamsFragment teamsFragment = new TeamsFragment();
data.putInt("current_page", index+1);
teamsFragment.setArguments(data);
return teamsFragment;
case 1:
data.putInt("current_page", index+1);
data.putInt("matchId", matchNum);
aFragment.setArguments(data);
return aFragment;
那么,如何会让碎片拨打他们的onResume()?