Skip to content Skip to sidebar Skip to footer

Binary Xml File Line #26: Duplicate Id, Tag Null, Or Parent Id With Another Fragment

I'm trying to insert a fragment to another and I’ve succeed to do this until I’ve lunch the main fragment for the first time it's working but when I’m trying to reload the fr

Solution 1:

I just ran into the same problem and could solve it by removing the fragment in the onDismiss callback.

@OverridepublicvoidonDismiss(DialogInterface dialog) {
    super.onDismiss(dialog);

    if (getActivity() != null) {
        FragmentManagerfragmentManager= getActivity().getFragmentManager();
        Fragmentfragment= fragmentManager.findFragmentById(R.id.sourcr_autocomplete_fragment);
        FragmentTransactionfragmentTransaction= fragmentManager.beginTransaction();
        fragmentTransaction.remove(fragment);
        fragmentTransaction.commit();
    }
}

Solution 2:

overide the onDestroyView method in the fragment

publicvoidonDestroyView() {
    super.onDestroyView();
    FragmentManagerfragmentManager= getActivity().getSupportFragmentManager();
    Fragmentfragment= fragmentManager.findFragmentById(R.id.sourcr_autocomplete_fragment);
    FragmentTransactionfragmentTransaction= fragmentManager.beginTransaction();
    fragmentTransaction.remove(fragment);
    fragmentTransaction.commit();
}

kotlin:

overridefunonDestroyView() {
    super.onDestroyView()
    activity?.supportFragmentManager?.also { fragmentManager ->
        fragmentManager.findFragmentById(R.id.aboutFragment)?.also { fragment ->
            fragmentManager.beginTransaction().remove(fragment).commit()
        }
    }
}

Post a Comment for "Binary Xml File Line #26: Duplicate Id, Tag Null, Or Parent Id With Another Fragment"