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 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, I press delete in the list view and delete the last item in the list, and I try to delete the fragment so that nothing is displayed, but it does not work, my fragment remains on the screen. Code to remove:
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?
Davejohnston
source share