I have a layout for landscape mode that shows a ListView on the left and a FrameLayout on the right. When an item is selected from the list another fragment is added to the FrameLayout
MyFragment myFragment = (MyFragment) fragmentManager.findFragmentById(R.id.myFrameLayout);
FragmentTransaction ft = fragmentManager.beginTransaction();
if (myFragment == null) {
myFragment = new MyFragment(uri);
ft.replace(R.id.myFrameLayout, playerFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commitAllowingStateLoss();
}
Later on I press delete in the list view and remove the last item in the list, and I try to remove the fragment so that nothing is shown, but it doesn't work, my fragment remains on the screen. The code for removing is:
MyFragment myFragment = (MyFragment) fragmentManager.findFragmentById(R.id.myFrameLayout);
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.remove(myFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
ft.commitAllowingStateLoss();
Any ideas why it is not being removed from the View?