Fragment getArguments() returns null

前端 未结 1 942
小鲜肉
小鲜肉 2020-12-15 18:15

I have a Fragment which has a TabHost as the root layout as follows...




        
相关标签:
1条回答
  • 2020-12-15 18:46

    I'm thinking this has to do with your problem:

    fm.beginTransaction()
        .replace(placeholder, new EpgEventListFragment(), tabId)
        .commit();
    

    You're making a new Fragment (that doesn't have arguments since it's been freshly instantiated).

    Instead try

    Fragment fragment = new EpgEventListFragment();
    fragment.setArguments(arguments);
    fm.beginTransaction()
        .replace(placeholder, fragment, tabId)
        .commit();
    
    0 讨论(0)
提交回复
热议问题