Fragments within Fragments

前端 未结 6 575
名媛妹妹
名媛妹妹 2020-11-22 09:47

I\'m wondering if this is actually a bug in the Android API:

I have a setup like so:

┌----┬---------┐
|    |         |
|  1 |    2    |
|    |┌------         


        
6条回答
  •  清酒与你
    2020-11-22 10:30

    .. you can cleanup your nested fragment in the parent fragment's destroyview method:

    @Override
        public void onDestroyView() {
    
          try{
            FragmentTransaction transaction = getSupportFragmentManager()
                    .beginTransaction();
    
            transaction.remove(nestedFragment);
    
            transaction.commit();
          }catch(Exception e){
          }
    
            super.onDestroyView();
        }
    

提交回复
热议问题