I am trying to add nested child Fragments into a parent Fragment.

All works fine but....

At first my code:

public class FragmentDatasheetWithHeader extends Fragment {


   private long   mRowId;
   private String mSid;


   @Override
   public View onCreateView(final LayoutInflater inflater, final
ViewGroup container, final Bundle savedInstanceState) {

      final ScrollView scrollView = new ScrollView(getActivity());
      final LinearLayout linearLayout = new LinearLayout(getActivity());
      linearLayout.setId(4711);
      linearLayout.setOrientation(LinearLayout.VERTICAL);

      scrollView.addView(linearLayout);

      createUI();

      return scrollView;
   }

   private void createUI() {

      final FragmentProductDetailHeader fragmentHeader =
FragmentProductDetailHeader.newInstance(this.mRowId,
FragmentProductDetailHeader.HEADERTYPE_SMALL);
      final FragmentDatasheet fragmentDatasheet =
FragmentDatasheet.newInstance(this.mRowId, this.mSid);

      final FragmentManager fragmentManager = getChildFragmentManager();
      fragmentManager.beginTransaction().add(4711, fragmentHeader,
"fragmentHeader").commit();
      fragmentManager.beginTransaction().add(4711, fragmentDatasheet,
"fragmentDatasheet").commit();
   }
}

Now my problem:

In the Developer options I activated "Don't keep activities (Destroy
every activity as soon the user leaves it)"

When the activity with the FragmentDatasheetWithHeader is open and the
app goes into background and comes back to foreground the nested
Fragments are doubled. But it only appears if the container for the
nested Fragments is a LinearLayout. If the container is a FrameLayout
the nested Fragments are not doubled.

What's going wrong?


Ralph

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to