getSupportFragmentManager().getFragments() shows a compile time error

前端 未结 3 867
小蘑菇
小蘑菇 2020-12-05 04:14

Calling getSupportFragmentManager().getFragments() shows a compile time error with the message below:

getSupportFragmentManager().getFrag

3条回答
  •  执笔经年
    2020-12-05 04:37

    Alternative For those who may be using getFragments() in their coding, I have replaced my code to get last fragment in backstack to this code(I am using this code in onBackPressed() to apply changes according to currentFragment assumed all fragments are added to backstack):

    FragmentManager.BackStackEntry backStackEntryAt = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
    currentFragment = backStackEntryAt.getName();
    

提交回复
热议问题