I\'m trying make an app that I\'m building take a search term from the main activity, return results, and then have the results be clickable such that a detail could be view
You can extend you fragment (which you load in xml) from XmlFragment. It handles parent FragmentManager and removes itself.
public class XmlFragment extends BaseFragment {
@Override
public void onDestroyView() {
Fragment parentFragment = getParentFragment();
FragmentManager manager;
if (parentFragment != null) {
// If parent is another fragment, then this fragment is nested
manager = parentFragment.getChildFragmentManager();
} else {
// This fragment is placed into activity
manager = getActivity().getSupportFragmentManager();
}
manager.beginTransaction().remove(this).commitAllowingStateLoss();
super.onDestroyView();
}
}