Android FragmentStatePagerAdapter, how to tag a fragment to find it later

前端 未结 9 1232
独厮守ぢ
独厮守ぢ 2020-12-24 14:09

When using the FragmentStatePageAdapter I get the fragments like this:

    @Override
    public Fragment getItem(int position) {
        return          


        
9条回答
  •  温柔的废话
    2020-12-24 15:04

    As @Lancelot mentioned, You may just call and cast result to your SuperCoolFragment:

    SuperCoolFragment frag = (SuperCoolFragment) yourFragmentStatePageAdpater.instantiateItem(null, position); 
    

提交回复
热议问题