android Fragment再次显示时调用的方法


@Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        Log.e(TAG, "onHiddenChanged:1 " );
        if (this != null && !hidden) {
            Log.e(TAG, "onHiddenChanged:2 " );
            ToastUtils.newToast(getContext(),"2");
        }
    }

或者:


  for (int i = 0; i < 5; i++) {
            MyOrderFragment mainFragmentList = new MyOrderFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("ORDERSTATE", i);
            mainFragmentList.setArguments(bundle);
            fragmentList.add(mainFragmentList);
        }

        viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), fragmentList));
        viewPager.setOffscreenPageLimit(0);//预加载
        mBottomNavigationTabStrip.setViewPager(viewPager, index);
 viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {
            }

            @Override
            public void onPageSelected(int i) {
                fragmentList.get(i).onResume();//关键方法                
            }

            @Override
            public void onPageScrollStateChanged(int i) {
            }
        });

你可能感兴趣的:(android Fragment再次显示时调用的方法)