2016年8月11日 星期四

after rotate the spinder can’t control the fragment

after rotate, the spider can’t control the fragment

it is because the reference to the fragment lost after rotate,(the activity create again,show lost),but the fragment still here,we just need to find it bu tha

I find the the savedInstanceState auto,so we can

use  if (savedInstanceState == null) {

           mainFragment = new MainFragment();
           Logger.d("create a mainFragment");
           fragmentTransaction.add(R.id.frame_layout_main, mainFragment);
           fragmentTransaction.commit();

       }


and find that mainFragment is null after rotate,so we need to get it back