The fragment does not work out visually

I am trying to replace the Fragment with a new fragment. For this, I used the following code.

transaction.replace (R.id.fragment_container, newFragment);

But when viewed in AVD, it is not actually replaced. newFragment (which is smaller) is displayed on top of the old_fragment.

However, when accessing old_fragment again, it returns null.

I even tried

Fragment oldFragment =. GetFragmentManager () findFragmentById (R.id.home_fragment); transaction.remove (oldFragment);

Even this is not a visual removal of a fragment.

Could you help me in removing any fragment.

PS: I use the Android compatibility package and create it for Android 2.2.

+4
source share
1 answer

This is some kind of behavior with Android Fragments.

If you have a fragment added to the XML layout, then the fragments in this step cannot be deleted. However, it works correctly if all fragments are added dynamically.

Strange, isn't it?

for reference see. http://groups.google.com/group/android-developers/browse_thread/thread/b56967e0f147168d

+3
source

All Articles