0

I Tried putting a Fragment into a FrameLayout inside another Fragment via FragmentManager and FragmentTransaction (from android.support.v4.app). The container fragment has a button and a TextView on top and a FrameLayout at the bottom (I create the layout programmatically and i don't want to hurt your eyes with all of that). The CreateView() works just fine and i cann access the FrameLayout at the bottom of the container and add or remove View dynamically as I please via

@Override
public void onClick(View button) {      
    FrameLayout frame = (FrameLayout)findViewById(DETAIL_CONTENT_FRAME);
    ImageView im = new ImageView(this);
    im.setImageResource(R.drawable.test);
    frame.addView(im);
}

but when I try to add a fragment instead of an ImageView to the frameLayout the code compiles perfectly but the desired fragment doesn't appear after the onClickListener() method is called. I checked the onCreateView() method of the fragment and it returns a proper view...

@Override
public void onClick(View button) {
    ServerDialogFragment serverDialog = new ServerDialogFragment();
    FragmentTransaction addDialog = getSupportFragmentManager().beginTransaction();
    addDialog.add(DETAIL_CONTENT_FRAME, serverDialog);
    addDialog.commit();
}

Do you have an answer to this ?

PS: I once tried adding fragments into other fragments and it worked, but they were simple fragments only holding ImageViews.

4

1 に答える 1

1

Fragments inside of other fragments is not supported at this time. See:

于 2011-09-06T14:57:45.333 に答える